Increment values

siddharth_kale

New Member
Joined
Dec 29, 2010
Messages
24
Hi,

I would like to use the below function by specifying a range of cells. Can someone help here:

Sub Up_One()
Range("C4").Value = Range("C4").Value + 1
Range("C5").Value = Range("C5").Value + 1
Range("C6").Value = Range("C6").Value + 1
End Sub

Instead of mentioning each cell I would like to directly mention C4:C6.

Any help is appreciated.

Regards,
Siddharth
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You can use a loop:

Code:
Sub Up_One()
    Dim Cell As Range
    For Each Cell In Range("C4:C6")
        Cell.Value = Cell.Value + 1
    Next Cell
End Sub
 
Upvote 0
Andrew, is there any way of using PasteSpecial to do the adding?

I'm just thinking out loud...
 
Upvote 0
Andrew, is there any way of using PasteSpecial to do the adding?

I'm just thinking out loud...

Yes, you could put 1 in a cell, copy it and paste special add.

Code:
Sub Up_One()
    With Range("A1")
        .Value = 1
        .Copy
        Range("C4:C6").PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd
        .ClearContents
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,834
Members
449,471
Latest member
lachbee

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