![]() |
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?? |
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?? |
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) |
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) |
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) |
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 |
All times are GMT +1. The time now is 03:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com