Daniel G. Gabori
Daniel G. Gabori

Reputation: 65

Excel Macro adding value to cells

I would like to ask for some help regarding Excel macros.

I have a column full of data, and I want to create a macro that when i run it, it adds "1" to each cell in that column, instead of having to type "1" in all 300 cells. Any suggestions? Thanks for the help.

Upvotes: 1

Views: 50120

Answers (1)

Gary's Student
Gary's Student

Reputation: 96791

To place a "1" in the cells:

Sub Place1()
    Range("A1:A300").Value = 1
End Sub

To add "1" to the current value in the cells:

Sub Add1()
    For Each r In Range("A1:A300")
        r.Value = r.Value + 1
    Next r
End Sub

Upvotes: 5

Related Questions