Akshay07 Posted November 19, 2009 Share Posted November 19, 2009 (edited) 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 November 19, 2009 by Akshay07 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 19, 2009 Share Posted November 19, 2009 (edited) 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 November 19, 2009 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 More sharing options...
Akshay07 Posted November 20, 2009 Author Share Posted November 20, 2009 (edited) 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 Edit: thanks for your help, it works! Edited November 20, 2009 by Akshay07 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 20, 2009 Share Posted November 20, 2009 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 More sharing options...
Akshay07 Posted November 27, 2009 Author Share Posted November 27, 2009 Thank you for the tip! 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