Offset not working with variable
Turns out it was working, and I had another mistake in my code causing
it to look like it wasnt working.
Silly me.
On Jun 11, 9:38 am, B wrote:
I might need to clarify that in the code I posted, there are two times
whereOffsetis used with avariable. ThevariableI'm having trouble
with is "HoursCol." But in response, thevariableis public.
On Jun 11, 8:52 am, Mike H wrote:
How have you declared thevariable? If you are passing it between subroutines
then it needs to be public
Public i As Integer
Mike
"B" wrote:
I'm trying to use Offest with avariableas the rowoffset. When run,
the line does nothing. When I replace thevariablewith an integer,
it works fine. Heres the code:
' This is where thevariableis 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 he
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.- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
|