B
B
I'm trying to use Offest with a variable as the row offset. When run,
the line does nothing. When I replace the variable with an integer,
it works fine. Heres the code:
' This is where the variable is assigned a value
If InStr(1, UCase(ActiveCell.Offset(0, i).Value), "HOURS") > 0 Then
HoursCol = ActiveCell.Offset(0, i).Column
' It then gets passed to this sub
Public Sub FindWrapperTotals(...HoursCol As Integer, ...)
' Used here:
MsgBox ("HoursCol = " & HoursCol)
HoursNum = ActiveCell.Offset(0, HoursCol - 1).Value
MsgBox ("HoursNum = " & HoursNum)
When run, the first message box says "HoursCol = 8", which is correct,
and the second message box says "HoursNum = ". When I replace
"HoursCol - 1" with an integer, it does exactly what I need...but of
course, life isn't simple enough to always use integers. Thanks in
advance for any advice.
the line does nothing. When I replace the variable with an integer,
it works fine. Heres the code:
' This is where the variable is assigned a value
If InStr(1, UCase(ActiveCell.Offset(0, i).Value), "HOURS") > 0 Then
HoursCol = ActiveCell.Offset(0, i).Column
' It then gets passed to this sub
Public Sub FindWrapperTotals(...HoursCol As Integer, ...)
' Used here:
MsgBox ("HoursCol = " & HoursCol)
HoursNum = ActiveCell.Offset(0, HoursCol - 1).Value
MsgBox ("HoursNum = " & HoursNum)
When run, the first message box says "HoursCol = 8", which is correct,
and the second message box says "HoursNum = ". When I replace
"HoursCol - 1" with an integer, it does exactly what I need...but of
course, life isn't simple enough to always use integers. Thanks in
advance for any advice.