Nurav Posted December 9, 2010 Share Posted December 9, 2010 I have this piece of code for generating an excel graph. Can some one help me in defining the "Range" in a different numerical way? ex. can i set the range as 1,1:2,2 instead of A1:B2? (This is not working anyway!) thanks in advance. Dim $oXL ;2 $oXL = ObjGet($FilePath) $oXL.Windows(1).Visible = 1 $oXL.Worksheets(1).Activate $oXL.ActiveSheet.Visible = 1 $oXL.Application.Visible = 1 $oXL.Charts.add() $oXL.ActiveChart.ChartType =51 ;bar chart= 51 $oXL.ActiveChart.SetSourceData($oXL.Worksheets(1).Range(A1:B2)) RichardL 1 Link to comment Share on other sites More sharing options...
JoHanatCent Posted December 9, 2010 Share Posted December 9, 2010 (edited) You can select your range like this: $oXL.Range("A1" ).Select $oXL.Range($oXL.ActiveCell.Offset(0, 0), $oXL.ActiveCell.Offset(6, 1) ).Select Edited December 9, 2010 by JoHanatCent Link to comment Share on other sites More sharing options...
water Posted December 9, 2010 Share Posted December 9, 2010 I use the following code written by Spiff58 to convert numbers into columns.; =============================================================================================================================== ; Convert column numbers to excel column letters ; Written by Spiff59 ; http://www.autoitscript.com/forum/index.php?showtopic=115665 ; =============================================================================================================================== Func _ExcelColumnLetter($iColumn = 0) Local $letters While $iColumn $x = Mod($iColumn, 26) If $x = 0 Then $x = 26 $letters = Chr($x + 64) & $letters $iColumn = ($iColumn - $x) / 26 WEnd Return $letters EndFunc RichardL 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Nurav Posted December 9, 2010 Author Share Posted December 9, 2010 You can select your range like this: $oXL.Range("A1" ).Select $oXL.Range($oXL.ActiveCell.Offset(0, 0), $oXL.ActiveCell.Offset(6, 1) ).Select Selecting a range with reference to the current active cell seems to be a workaround. I am wondering if there is an absolute way to do this. Please refer this topic: http://www.xtremevbtalk.com/showthread.php?t=112863 there it says, The Range() property (essentially is a function) cannot accept R1C1-style notation for the input string. It can take either strings of A1 notation, or Cell/Range inputs. The following all *attempt* to Select the same Range: Range("A1:E10").Select ' Works fine. Range("R1C1:R5C10").Select ' FAILS! Range(Cells(1, 1), Cells(5, 10)).Select ' Works fine. What can be the AutoIt equivalent of last statement? (Range(Cells(1, 1), Cells(5, 10)).Select) Link to comment Share on other sites More sharing options...
water Posted December 9, 2010 Share Posted December 9, 2010 According to the Excel UDF function _ExcelNumberFormat the last example (Range(Cells(1, 1), Cells(5, 10)).Select ) should read: With $oExcel.ActiveSheet .Range(.Cells($sRangeOrRowStart, $iColStart), .Cells($iRowEnd, $iColEnd) ).Select EndWith RichardL 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
JoHanatCent Posted December 9, 2010 Share Posted December 9, 2010 (edited) What can be the AutoIt equivalent of last statement? (Range(Cells(1, 1), Cells(5, 10)).Select) Try: $oXL.Range($oXL.Cells(1, 1), $oXL.Cells(6, 2)).Select Edited December 9, 2010 by JoHanatCent Link to comment Share on other sites More sharing options...
Nurav Posted December 9, 2010 Author Share Posted December 9, 2010 Try: $oXL.Range($oXL.Cells(1, 1), $oXL.Cells(6, 2)).Select $oXL.ActiveChart.SetSourceData($oXL.Range($oXL.Worksheets(1).Cells(1, 1), $oXL.Worksheets(1).Cells(11, 5))) This worked like a charm! thank you all... @water: now we don't need a function to convert number to alphabet! Yeeeeeee!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now