Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default macro to increment/decrement values in selected cells

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,xlR1 C1)

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default macro to increment/decrement values in selected cells

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

"Sunny" wrote:

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,xlR1 C1)

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default macro to increment/decrement values in selected cells

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.

"OssieMac" wrote:

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

"Sunny" wrote:

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,xlR1 C1)

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell math to decrement/increment a cell BUFFETT Excel Worksheet Functions 1 June 16th 06 08:37 PM
Macro to take selected cells times a selected cell Craig Excel Programming 4 October 24th 05 12:54 AM
How do I increment or decrement values in a column? OldKenGoat New Users to Excel 3 January 6th 05 01:05 AM
Provide increment and decrement buttons on toolbar line ExcelStudent Excel Programming 1 October 3rd 04 07:39 AM
Spin Button to increment or decrement the date in cell A1 Pal Excel Programming 5 August 4th 03 11:43 AM


All times are GMT +1. The time now is 02:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"