+ Reply to Thread
Results 1 to 2 of 2

How do I call this function?

  1. #1
    vrk1
    Guest

    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!


  2. #2
    JE McGimpsey
    Guest

    Re: How do I call this function?

    One way:

    x = lastincolumn(Sheets("Sheet1").Range("C:C"))

    In article <[email protected]>,
    "vrk1" <[email protected]> wrote:

    > 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1