Nurav 1 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)) 1 RichardL reacted to this Share this post Link to post Share on other sites
JoHanatCent 13 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 Share this post Link to post Share on other sites
water 2,424 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 1 RichardL reacted to this My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Nurav 1 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) Share this post Link to post Share on other sites
water 2,424 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 1 RichardL reacted to this My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
JoHanatCent 13 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 Share this post Link to post Share on other sites
Nurav 1 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!!!! Share this post Link to post Share on other sites