=1+A2 in VBA

Tooltime12

New Member
Joined
Oct 16, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have a worksheet range is A1:I200. Running some functions manually, excel Script and VBA. No formal training with any. Currently cell value for A2:A200 is 1. I’m trying to figure out how to increment the value by 1 every 20 rows, for 20 rows (A2:A21=1,A22:A41=2,A42:A61=3……). Currently I’m changing A:22 to =1+A2, auto filling down, then copy/paste append before running additional VBA code. Tried several ways and searched various forums but can’t seem to get it working.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Welcome to the Forum!

Here's one way you could do it:

VBA Code:
With Range("A2:A201")
    .ClearContents
    .Cells(1).Formula2 = "=1+INT(SEQUENCE(200,,0)/20)"
    .Value = .Value
End With
 
Upvote 1
Solution
Try below code
PHP:
Sub test()
With Range("A2:A200")
    .Formula = "=INT((ROW()-1)/20)+1"
    .Value = .Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,109
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