LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Offset not working with variable

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 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.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
select offset (variable ,1) to offset(variable ,variable) Buffyslay Excel Programming 1 November 15th 06 11:45 AM
Offset with variable? John Excel Programming 3 June 30th 06 08:30 PM
Offset with variable? John Excel Programming 1 June 30th 06 08:11 PM
offset not working BorisS Excel Discussion (Misc queries) 2 November 30th 05 08:15 AM
Offset with variable James Excel Programming 2 August 16th 05 08:27 PM


All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"