Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I created a function in excel and I want to use it in my VBA and I don't know
how to refer to the range Function PD(func As String, ai As Double, Zi As String, rng As Range) Say my range is A1:A4 How do I set rng = A1:A4 Any help |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
rng = Range("A1:A4")
You may need to reference the sheet as well: rng = Sheets("mysheet").Range("A1:A4") "Ali Baba" wrote: I created a function in excel and I want to use it in my VBA and I don't know how to refer to the range Function PD(func As String, ai As Double, Zi As String, rng As Range) Say my range is A1:A4 How do I set rng = A1:A4 Any help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ali,
When you call the function from your worksheet, simply pass it the address of the range as the fourth parameter: =PD("Func Input",1234.56, "Zi input", A1:A4) or they could all be range references: Excel will take them in order an assign them to the variables: =PD(B1,C1,D1,A1:A4) When calling the function from VBA, you need to be a little better at specifics: MyValue =PD("Func Input",1234.56, "Zi input", Range("A1:A4")) myValue=PD(Range("B1"),Range("C1"),RAnge("D1"),Ran ge("A1:A4")) It may also be necessary to specify which worksheet object the range object comes from. To fully identify the range , change Range(...) to Worksheets("Sheet name").Range("A1:A4") HTH, Bernie MS Excel MVP "Ali Baba" wrote in message ... I created a function in excel and I want to use it in my VBA and I don't know how to refer to the range Function PD(func As String, ai As Double, Zi As String, rng As Range) Say my range is A1:A4 How do I set rng = A1:A4 Any help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Range problem | Excel Programming | |||
Range problem | Excel Programming | |||
getting value of range problem | Excel Programming | |||
Range problem | Excel Programming | |||
Used Range Problem | Excel Programming |