LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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 -



 
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 11:16 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"