Jump to content
Sign in to follow this  
Akshay07

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

Recommended Posts

Akshay07

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
Akshay07

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.