LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default How do I call this function?

I have a function as follows in my Excel module:

Function LASTINCOLUMN(rngInput As Range)
Dim WorkRange As Range
Dim i As Integer, CellCount As Integer
Application.Volatile
Set WorkRange = rngInput.Columns(1).EntireColumn
Set WorkRange = Intersect(WorkRange.Parent.UsedRange, WorkRange)
CellCount = WorkRange.Count
For i = CellCount To 1 Step -1
If Not IsEmpty(WorkRange(i)) Then
LASTINCOLUMN = WorkRange(i).Row
Exit Function
End If
Next i
End Function



If I call this function an Excel worksheet with the formula
"=lastincolumn(sheet1!c:c)" it works!

However, this doesnt work when I call this function from inside VBA.

for instance when I say x = lastincolumn("Sheet1!c:c")

Excel throws an error msg saying Type Mismatch

How do I call this function within VBA and assign this to a variable?

Please help!

 
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
Is there a do not call function? pokdbz Excel Discussion (Misc queries) 2 December 27th 07 04:00 PM
how i can call the function reneabesmer Excel Worksheet Functions 2 May 2nd 05 12:13 PM
call a function from VBA Adam Excel Programming 2 March 15th 05 10:17 AM
Function Call Phil Hageman Excel Programming 4 October 9th 03 04:32 PM
call function sirron Excel Programming 1 August 26th 03 03:39 PM


All times are GMT +1. The time now is 06:36 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"