Jump to content

Alternate "Range" notation in Excel.


Nurav
 Share

Recommended Posts

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))
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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...:x

@water: now we don't need a function to convert number to alphabet! Yeeeeeee!!!!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...