Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Please assist.
I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Which function ?
See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... Please assist. I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if, by function, you mean a UDF, just use
=myudfname(myparameter(s)) -- Don Guillett SalesAid Software "Gwen" wrote in message ... Please assist. I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to do something like this:
range("A1").value = lr() It doesn't work. Harlan's Function: Function lr(Optional r As Range) As Variant Dim ur As Range, c As Range, i As Long, n As Long 'there arguments for & against volatility - optional to uncomment Application.Volatile If r Is Nothing Then Set r = Application.Caller If Not TypeOf r Is Range Then Set r = ActiveCell Set ur = r.Parent.UsedRange n = ur.Rows.Count For i = n To 1 Step -1 Set c = ur.Cells(i, 1) If Not IsEmpty(c.Value) Then Exit For If Not IsEmpty(c.End(xlToRight).Value) Then Exit For Next i lr = ur.Row + i - 1 End Function "Ron de Bruin" wrote: Which function ? See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... Please assist. I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why not enter the formula with code
Sub test() Dim sh As Worksheet For Each sh In ActiveWorkbook.Worksheets With sh.Range("A1") .Formula = "=lr()" '.Value = .Value End With Next sh End Sub Have you try the other function ? This one is working correct -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... I am trying to do something like this: range("A1").value = lr() It doesn't work. Harlan's Function: Function lr(Optional r As Range) As Variant Dim ur As Range, c As Range, i As Long, n As Long 'there arguments for & against volatility - optional to uncomment Application.Volatile If r Is Nothing Then Set r = Application.Caller If Not TypeOf r Is Range Then Set r = ActiveCell Set ur = r.Parent.UsedRange n = ur.Rows.Count For i = n To 1 Step -1 Set c = ur.Cells(i, 1) If Not IsEmpty(c.Value) Then Exit For If Not IsEmpty(c.End(xlToRight).Value) Then Exit For Next i lr = ur.Row + i - 1 End Function "Ron de Bruin" wrote: Which function ? See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... Please assist. I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is exactly what I wanted to do. It Works like a charm
Okay I will give the last row function another try. Did you write that code by chance? Thanks a bunch! "Ron de Bruin" wrote: Why not enter the formula with code Sub test() Dim sh As Worksheet For Each sh In ActiveWorkbook.Worksheets With sh.Range("A1") .Formula = "=lr()" '.Value = .Value End With Next sh End Sub Have you try the other function ? This one is working correct -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... I am trying to do something like this: range("A1").value = lr() It doesn't work. Harlan's Function: Function lr(Optional r As Range) As Variant Dim ur As Range, c As Range, i As Long, n As Long 'there arguments for & against volatility - optional to uncomment Application.Volatile If r Is Nothing Then Set r = Application.Caller If Not TypeOf r Is Range Then Set r = ActiveCell Set ur = r.Parent.UsedRange n = ur.Rows.Count For i = n To 1 Step -1 Set c = ur.Cells(i, 1) If Not IsEmpty(c.Value) Then Exit For If Not IsEmpty(c.End(xlToRight).Value) Then Exit For Next i lr = ur.Row + i - 1 End Function "Ron de Bruin" wrote: Which function ? See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... Please assist. I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, =lr() works fine when I entered it manually.
But I needed a way to get that function in a cell programatically. "Don Guillett" wrote: I may be misunderstanding what you want but did you look at my previous answer =lr() -- Don Guillett SalesAid Software "Gwen" wrote in message ... I am trying to do something like this: range("A1").value = lr() It doesn't work. Harlan's Function: Function lr(Optional r As Range) As Variant Dim ur As Range, c As Range, i As Long, n As Long 'there arguments for & against volatility - optional to uncomment Application.Volatile If r Is Nothing Then Set r = Application.Caller If Not TypeOf r Is Range Then Set r = ActiveCell Set ur = r.Parent.UsedRange n = ur.Rows.Count For i = n To 1 Step -1 Set c = ur.Cells(i, 1) If Not IsEmpty(c.Value) Then Exit For If Not IsEmpty(c.End(xlToRight).Value) Then Exit For Next i lr = ur.Row + i - 1 End Function "Ron de Bruin" wrote: Which function ? See your other thread -- Regards Ron de Bruin http://www.rondebruin.nl "Gwen" wrote in message ... Please assist. I have been trying to place the function in cell A1 fo every sheet and run it programmatically? The function is in a module. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Enter data into a cell that already has a function. | Excel Worksheet Functions | |||
How do I enter a cell value into the Timevalue() function? | Excel Worksheet Functions | |||
How to Enter data and Function in same cell | Excel Discussion (Misc queries) | |||
Using a function in a macros to enter data in a specified cell | Excel Programming | |||
change font colour if cell contains function - programmatically | Excel Programming |