Consulting

Results 1 to 4 of 4

Thread: Find Column Difference

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Find Column Difference

    I created a Function to find the column difference between whatever column number I pass to the function and what ever column it finds a particular string in. It was working, however it isn't working anymore and when I tested it and watched the value it says "<Expression not defined in Context>". Here is the function:

    [vba]Function fnFindColumnDif(ByVal lColtoSubtract As Integer, ByVal sToFind As String) As Integer

    Dim lColSubtractFrom As Integer

    'Find Column# to Subtract
    lColSubtractFrom = Range(Cells(1, 1), Cells(1, FinalColumn(wsWorking))).Find(What:=sToFind).Column
    'Find Column Difference
    fnFindColumnDif = lColSubtractFrom - lColtoSubtract

    End Function[/vba]

    I also watched the lColSubtractFrom and it was correct and I watched lColtoSubtract and it was also correct but they aftert the last line finFindColumnDif is still empty and says "<Expression not defined in Context>" in the value column.

    Does anyone know what "<Expression not defined in Context>" means?
    Last edited by Djblois; 11-21-2007 at 10:07 AM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You have got a variable in there, wsWorking, that is not being populated. What is it?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    That is a public Variable defining the worksheet being worked on.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Assuming that FinalColumn(wsWorking) returns a valid value, it works fine for me.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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