VBA: add +1 in column A

Laurens1

New Member
Joined
Dec 9, 2016
Messages
31
Hi Guys,

I want to add a number to each row, starting on A3 with 0, A4 1, A5 2, etc. Until the last row in column B is reached.

Can you guys help me?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Is there already something in those cells, or are they blank?
So are you wanting to add to what is currently in those cells, or just override them with 0,1,2,...?
 
Upvote 0
cells in column A are empty. iI want to count the filled cells in column B, starting from B3 till the last row
 
Upvote 0
Try this:
Code:
    Dim rng As Range
    Set rng = Range("A3:A" & Cells(Rows.Count, "B").End(xlUp).Row)
    rng.Formula = "=ROW()-3"
    rng.Value = rng.Value
Without VBA, simply enter this formula in cell A3:
Code:
=ROW()-3
and double-click to autofill down to the last row.
 
Upvote 0
It must be VBA... I try to keep the macro of somebody else alive. Some inheritance from someone who knew what he did. :biggrin:

But it works, thanks a lot!!!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

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