macro to increment/decrement values in selected cells

S

Sunny

Hi
I am trying to write a macro to increment/decrement the values in a range of
selected cells (e.g. R3C3:R8C10).

I got as far as returning the address of the selected cells ("R3C3:R8C10")
using:
ActiveWindow.RangeSelection.address(True,True,xlR1C1)

Now how do I use these address "corners" to cycle through the cells?
Range() and Cell() seem to require a different format.

Or, is there a simpler way to add/subtract/multiply a selected range of
cells by another value?

Thanks
 
O

OssieMac

sunny,

If you want to multiply a range of cells by 10 then enter 10 into any blank
cell.

Copy the cell then select the range to be modified, Paste Special, Multiply.

See the other options in the paste special dialog box.

Regards,

OssieMac
 
S

Sunny

Thanks for the quick reply.
I tried to incorporate the PasteSpecial into a macro with mixed results.

If I use a CommandButton, the instructions worked.

Private Sub CommandButton1_Click()
Address = ActiveWindow.RangeSelection.Address(True, True, xlA1)
Range("A18").Select
Selection.Copy
Range(Address).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlAdd, SkipBlanks:=False _
, Transpose:=False

End Sub

However, when I try to use the SpinButton, it fails.

Private Sub SpinButton1_SpinUp()
Address = ActiveWindow.RangeSelection.Address(True, True, xlA1)
Increment = SpinButton1.LinkedCell
Range(Increment).Select
Selection.Copy
Range(Address).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlAdd, SkipBlanks:=False _
, Transpose:=Fals
End Sub

Confued.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top