View Full Version : Find Column Difference

11-21-2007, 09:19 AM
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:

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

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?

Bob Phillips
11-21-2007, 10:21 AM
You have got a variable in there, wsWorking, that is not being populated. What is it?

11-21-2007, 10:23 AM
That is a public Variable defining the worksheet being worked on.

Bob Phillips
11-21-2007, 10:30 AM
Assuming that FinalColumn(wsWorking) returns a valid value, it works fine for me.