Macro needs to operate on rows with "start" through "end"

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
How do I create a macro that makes calculations starting just after a row (with "Qty" in col A) UP to a row that contains a unique entry called "Grand Total"
(in say Column B)

Calculation are like:
G8 = a8*e8 and
H8 = a8*e8-d8 etc
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I like to use the Cells array for things like this.

dim i as integer
dim bStart as Boolean

bStart = False

For i = 1 to 100

if cells(i,2).value = "Grand Total" then Exit For

if bStart = True then

Cells(i,7).value = cells(i,1).value * cells(i,5).value
Cells(i,8).value = cells(i,7).value - cells(i,4).value
etc.

End If

if cells(i,1).value = "Qty" then bStart = True

Next

Hope this helps...

K
 
Upvote 0
Thanks,

Here is what I created, its errors at the ???

-----
Dim i As Integer
Dim bStart As Boolean

bStart = False

For i = 1 To 100

If Cells(i, 2).Value = "Grand Total" Then Exit For ' define end

If bStart = True Then
If Cells(i, 1).Value <> 0 Then ' insure there is a qty
If Cells(i, :cool: = 0 And Cells(i, 9) = 0 Then ' use vendor data from col E - Unit List
Cells(i, 10).Value = Cells(i, 1).Value * Cells(i, 5).Value
ElseIf Cells(i, :cool: > 0 Then ' use percentage discount from col H - Discount %
Cells(i, 10).Value = Cells(i, 1).Value * (Cells(i, 5).Value - Cells(i, 5).Value * Cells(i, :cool:.Value / 100) ' ?????
ElseIf Cells(i, 9) > 0 Then ' use specified value in col J - Unit selling price
Cells(i, 10).Value = Cells(i, 1).Value * Cells(i, 10).Value
End If


End If
End If

If Cells(i, 1).Value = "Qty." Then bStart = True ' define start
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,176
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top