Jump to content

Use a string varioable with $oExcel.Application.ActiveSheet.Range(C14).Select


Akshay07
 Share

Recommended Posts

Hello,

I would like to create a function which would select a different cell depending of the string sent to this function.

For example, if I want to select C14, I am trying somenthing like:

$sCell1 = "C14"
Call ( "SelectCell", $sCell1 )
; can I just write Call ( "SelectCell", "C14" ) ?

Func SelectCell ($sCellId)
    
    $oExcel.Application.ActiveSheet.Range( ?? what to write here ??).Select
    
EndFunc

Any hint would be welcome :)

Edited by Akshay07
Link to comment
Share on other sites

As it was received by the function input:

$oExcel.Application.ActiveSheet.Range($sCellId).Select

:)

Edit: But what's with the Call()? Just use:

SelectCell($sCell1)

;)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

As it was received by the function input:

$oExcel.Application.ActiveSheet.Range($sCellId).Select

:)

Edit: But what's with the Call()? Just use:

SelectCell($sCell1)

;)

Thanks a lot!

Hummm... strange, I tried to use $sCellId but it did not work. Maybe something else was wrong. Do I need to declare $sCellId somewhere?

I need Call() because in fact, I have much more going on in this function. I just wrote the essential to make it more clear B)

Edit: thanks for your help, it works!

Edited by Akshay07
Link to comment
Share on other sites

Do I need to declare $sCellId somewhere?

Listing the variable in the function declaration i.e. "Func SelectCell($sCellId)", automatically declares it Local and initializes it with the value passed when the function is called (or optional default value, if used). So no, you never need to declare the input variables in a function aside from the Func line.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...