Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Offsetting a varible??

I have this code:

Sub Subtotals()
Dim SubTot As Integer
Dim Line1 As Double

Sheets("Temp").Select
Range("H2").Select
Line1 = Range("L2")
SubTot = Range("P4")
Do Until ActiveCell = ("Condiments")

SubTot = Line1 + SubTot
ActiveCell.Offset(1, 0).Select
Line1 = Range.Offset(1, 0) 'Fails on this line!!!


Range("P4") = SubTot
Loop

Can anyone please help me on being able to step my varible "Line1" down a
row??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Offsetting a varible??

try

set line1 = line1.offset(1,0)
or
line1=line1.offset(1,0)

"Ashley Milford via OfficeKB.com" wrote:

I have this code:

Sub Subtotals()
Dim SubTot As Integer
Dim Line1 As Double

Sheets("Temp").Select
Range("H2").Select
Line1 = Range("L2")
SubTot = Range("P4")
Do Until ActiveCell = ("Condiments")

SubTot = Line1 + SubTot
ActiveCell.Offset(1, 0).Select
Line1 = Range.Offset(1, 0) 'Fails on this line!!!


Range("P4") = SubTot
Loop

Can anyone please help me on being able to step my varible "Line1" down a
row??

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Offsetting a varible??

thank gixxer but both of them say that the line1 in the [] are invaild
qualifiers. the code won't even compile it goes straight to the []'s. also
no i didn't put the [] in the code.

set line1 = [line1].offset(1,0)
line1=[line1].offset(1,0)
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Offsetting a varible??

wait, line1 is dimmed as a double so it can't be modified like that
try dimming line1 as range

Sub Subtotals()
Dim SubTot As Integer
Dim Line1 As Range

Sheets("Temp").Select
Range("H2").Select
set Line1 = Range("L2")
SubTot = Range("P4")
Do Until ActiveCell = ("Condiments")

SubTot = Line1 + SubTot ' may need to do SubTot = Line1.value + SubTot
ActiveCell.Offset(1, 0).Select
set Line1 = Line1.Offset(1, 0)


Range("P4") = SubTot
Loop

"Ashley Milford via OfficeKB.com" wrote:

thank gixxer but both of them say that the line1 in the [] are invaild
qualifiers. the code won't even compile it goes straight to the []'s. also
no i didn't put the [] in the code.

set line1 = [line1].offset(1,0)
line1=[line1].offset(1,0)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Offsetting a varible??

gixxer,
Tried that, worked but it would not offset the line1 cell. it looped till
the active cell was = to "Condiments" but only added the value of "L2" to
the subtot instead of offsetting it to the row below every loop.

Ashley


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Offsetting a varible??

Hard to know what you are trying to do with Line1, but your problem is the
Use of Range. I have substituted ActiveCell which should work for
eliminating the error, but don't know it is provides the functionality you
want.

Sub Subtotals()
Dim SubTot As Integer
Dim Line1 As Double

Sheets("Temp").Select
Range("H2").Select
Line1 = Range("L2")
SubTot = Range("P4")
Do Until ActiveCell = ("Condiments")

SubTot = Line1 + SubTot
ActiveCell.Offset(1, 0).Select
Line1 = ActiveCell.Offset(1, 0) 'Fails on this line!!!
Range("P4") = SubTot
Loop

--
Regards,
Tom Ogilvy


"Ashley Milford via OfficeKB.com" wrote in message
...
thank gixxer but both of them say that the line1 in the [] are invaild
qualifiers. the code won't even compile it goes straight to the []'s. also
no i didn't put the [] in the code.

set line1 = [line1].offset(1,0)
line1=[line1].offset(1,0)



Reply
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
same varible in formula jheiser57 Excel Worksheet Functions 0 June 21st 10 04:49 PM
varible calculation kinsey New Users to Excel 7 September 30th 07 08:50 AM
Range name as varible [email protected] Excel Programming 4 February 9th 05 03:31 PM
Varible in a Range mushy_peas[_11_] Excel Programming 3 January 17th 04 02:06 AM
how to start from varible row Vimal[_2_] Excel Programming 2 October 14th 03 08:44 AM


All times are GMT +1. The time now is 05:50 AM.

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"