For statement?

Gil149

Board Regular
Joined
Oct 11, 2010
Messages
144
I am trying to run this code, but I want to use something like a For statement for C to be equal to 3,6,11,17,22...is this possible?

Code:
A = 0
B = 0
C = 3
D = 19
Sheets("Totals").Select
        For Each rngcell In Range("A4:A" & Range("A" & Rows.Count).End(xlUp).Row)
            If rngcell.Value = Sheets("Warehouse").Range("C18").Value Then
                For I = 0 To 4
                    If rngcell.Offset(0, C + (13 * I)).Value <> "" Then
                        A = A + rngcell.Offset(0, C + (13 * I)).Value
                        B = B + 1
                    End If
                Next I
            End If
            Sheets("Warehouse").Range("C" & D).Value = A / B
        Next rngcell
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I don't see the pattern in the sequence and I'm not sure what you mean.

Did you mean for each loop, you want to use a different values of C which you can store?

Then you would need to make C as an array and insert the values into the C array and then make a separate (or same) counter to loop through the elements of the C array.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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