Macro to add 1 to 4th then 5th cell for 200 numbers

newshound12

Active Member
Joined
Feb 19, 2003
Messages
339
A different number is inputed in cell cd31 every day.
Today's number in cd31 is 401
Then I want CD35 to be 402
Then I want CD40 to be 403
Then I want CD44 to be 404
Then I want CD49 to be 405
until last cell: CD926 = 600

Need a macro to increase by 1 every 4th then 5th then 4th then 5th cell, etc.
Then .value = .value for the column of numbers
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Code:
Option Explicit


Sub Hound12()
    Dim crit As Long, i As Long
    crit = Range("CD31")
    Dim lr As Long
    lr = 926
    For i = 35 To lr Step 5
        Range("A" & i) = crit + 1
        crit = crit + 1
    Next i
End Sub
 
Upvote 0
Try


Code:
Dim myNumber as Double, rowNum As Long

With Range("CD:CD")
    MyNumber = .Cells(31,1).Value
    
    RowNumber = 35
    Do
        MyNumber = myNumber + 1
        .Cells(RowNumber,1).Value = myNumber
        MyNumber = myNumber + 1
        .Cells(RowNumber + 4, 1) = myNumber
        RowNumber = RowNumber + 9
    Loop Until RowNumber >=926

End With
 
Upvote 0
Thanks. It works when I modified it as follows:

Sub Hound12()
Dim myNumber As Double, rowNum As Long

With Range("CD:CD")
myNumber = .Cells(31, 1).Value

rowNum = 31
Do
myNumber = myNumber + 1
.Cells(rowNum, 1).Value = myNumber
myNumber = myNumber + 1
.Cells(rowNum + 4, 1) = myNumber
rowNum = rowNum + 9
Loop Until rowNum >= 926

End With
End Sub
 
Upvote 0
It did not work.


Not a helpful response.

Code:
Option Explicit


Sub Hound12()
    Dim crit As Long, i As Long
    crit = Range("CD31")
    Dim lr As Long
    lr = 926
    For i = 35 To lr Step 5
        Range("CD" & i) = crit + 1
        crit = crit + 1
    Next i
End Sub[COLOR=#333333]

[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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