Calling a function from within EXCEL

P

pcor

Hi
How do I CALL the function below.
Where do I place the code shown below
And how do I go about calling the function
Thanks

Sub FindLastCell()
Dim LastCell As Range
With ActiveSheet
Set LastCell = .Cells(.Rows.Count, "A").End(xlUp)
If IsEmpty(LastCell) Then
'do nothing
Else
Set LastCell = LastCell.Offset(1, 0)
End If
End With
MsgBox LastCell.Row
End Sub
 
T

Tom Ogilvy

go to the vbe and with your workbook as the active project, do
Insert=>Module. Place the code there. You can create another macro to call
it

Sub CallDemo()
Call FindLastCell()
End Sub

Regards,
Tom Ogilvy
 
P

pcor

That was a great help. Thanks
Is there a way to action that same code without using a macro?

Tom Ogilvy said:
go to the vbe and with your workbook as the active project, do
Insert=>Module. Place the code there. You can create another macro to call
it

Sub CallDemo()
Call FindLastCell()
End Sub

Regards,
Tom Ogilvy
 
T

Tom Ogilvy

Tools=>Macro=>Macros, select FindLastCell and hit the run button.

Regards,
Tom Ogilvy

pcor said:
That was a great help. Thanks
Is there a way to action that same code without using a macro?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top