Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter data into a cell that already has a function. alwayslearning Excel Worksheet Functions 2 October 25th 08 05:31 PM
How do I enter a cell value into the Timevalue() function? busterpace Excel Worksheet Functions 1 October 8th 06 02:23 AM
How to Enter data and Function in same cell [email protected] Excel Discussion (Misc queries) 3 October 2nd 06 07:10 PM
Using a function in a macros to enter data in a specified cell MaxRussell Excel Programming 2 November 26th 04 07:13 PM
change font colour if cell contains function - programmatically fitful_thought Excel Programming 3 October 30th 04 01:38 AM


All times are GMT +1. The time now is 09:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"