![]() |
How do I enter a function in a cell and run it programmatically??
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 |
How do I enter a function in a cell and run it programmatically??
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 |
How do I enter a function in a cell and run it programmatically??
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 |
How do I enter a function in a cell and run it programmaticall
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 |
How do I enter a function in a cell and run it programmaticall
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 |
How do I enter a function in a cell and run it programmaticall
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 |
How do I enter a function in a cell and run it programmaticall
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 |
All times are GMT +1. The time now is 03:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com