Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing a cells content into a macro
Cano1963 wrote: I have a problem. I need to pass the contents of a cell int to a macro. I dont want to use it in the arguments of the macro cause i would have to pass 20 argument. what i want to see if there is a way to use something like (example but this doesnt work If ActiveCell.Address(6, 7) = "refurb" Then equipmentcost = Active.worksheet3(3, 58) + Active.worksheet3!(3, 66)) notice i try and and use Activecell.address(r,c) or active.worksheet3!(r,c) i want to use these type statment to pass the argument. not Function equipmentcost(eqname As String, eqtype1 As String, eqtype2 As String, eqtype3 As String, eqtype4 As String, eqtype5 As String, eqtype6 As String, eqtype7 As String, eqamount1 As Integer) i dont want to put 20 or 30 that many items in there. please help cause i am stuck. if you guys have a differnet way to approach this please tell me. thanks I hope my english is ok so sorry if it is not .. Use ParamArray and loop through the array Function equipmentcost(paramarray eqname() as string) Dim i as integer For i = lbound(eqname) to ubound(eqname) 'do something Next i End Function If you use the paramarray, you won't have to worry about declaring all of those arguments individually. Just remember that the paramarray has to be the last argument in the function call (i.e. you must have function blah( str as string, paramarray newstr() as string), not function blah(paramarray newstr() as string,str as string) You might be better off passing a range to the function, then looping through it and checking for certain phrases instead of passing all of those strings, but I am not sure what you are doing, so I can't be sure. Let me know if this helps. I hope that helps. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro help: moving specific cells based upon content | Excel Worksheet Functions | |||
Macro to highlight cells based on content | Excel Worksheet Functions | |||
passing arguments from an excel macro to a word macro | Excel Discussion (Misc queries) | |||
macro - hiding rows given a cells content | Excel Programming | |||
passing variables from an excel macro to a powerpoint macro | Excel Programming |