#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default EXCEL MACRO 2007

I'm creating a spreadsheet for cost estimating and I have run into some
problems with the VBA code for macros to make the sheet do what I want.
I wrote yesterday for a macro that would raise the value of any given cell
by a certain percentage. I got the macro, and it worked, but if the control
button is pushed more than once the value continues to go up. (That makes
sense). Then I found that the "Undo" stack list is cleared when you run a
macro so this presents a problem. I need to be able to "Undo" if the control
button is pushed more than once. Also, if the cursor is inadvertantly in any
particular cell on the spreadsheet and the button is pushed the value will
increase by the predetermined %. I would like to restrict the range to a
certain group of cells only, and within that group I can pick which cell I
want to increase the value of. I went into the EXCEL registry to increase the
stack list number, but this still does not allow the "Undo" of a Macro.
Any advice?
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default EXCEL MACRO 2007

This is what I was given from this site:

Public Sub ChangePercent()
Dim rng As Range

On Error Resume Next
For Each rng In Selection
rng.Value = rng.Value * 0.5
Next rng

End Sub

I'm not a programmer, so I don't really know how to proceed at all.

"Don Guillett" wrote:


As always, post your macro for comments. No mind readers here.
You could put in a msgbox asking if you really want to increase and you can
restrict the range
Look at INTERSECT

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"BobF" wrote in message
...
I'm creating a spreadsheet for cost estimating and I have run into some
problems with the VBA code for macros to make the sheet do what I want.
I wrote yesterday for a macro that would raise the value of any given cell
by a certain percentage. I got the macro, and it worked, but if the
control
button is pushed more than once the value continues to go up. (That makes
sense). Then I found that the "Undo" stack list is cleared when you run a
macro so this presents a problem. I need to be able to "Undo" if the
control
button is pushed more than once. Also, if the cursor is inadvertantly in
any
particular cell on the spreadsheet and the button is pushed the value will
increase by the predetermined %. I would like to restrict the range to a
certain group of cells only, and within that group I can pick which cell I
want to increase the value of. I went into the EXCEL registry to increase
the
stack list number, but this still does not allow the "Undo" of a Macro.
Any advice?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default EXCEL MACRO 2007

Try

Public Sub ChangePercent()
Dim rng As Range

On Error Resume Next
Application.EnableEvents = False
For Each rng In Selection
rng.Value = rng.Value * 0.5
Next rng
Application.EnableEvents = True
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Thu, 9 Jul 2009 09:00:01 -0700, BobF
wrote:

This is what I was given from this site:

Public Sub ChangePercent()
Dim rng As Range

On Error Resume Next
For Each rng In Selection
rng.Value = rng.Value * 0.5
Next rng

End Sub

I'm not a programmer, so I don't really know how to proceed at all.

"Don Guillett" wrote:


As always, post your macro for comments. No mind readers here.
You could put in a msgbox asking if you really want to increase and you can
restrict the range
Look at INTERSECT

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"BobF" wrote in message
...
I'm creating a spreadsheet for cost estimating and I have run into some
problems with the VBA code for macros to make the sheet do what I want.
I wrote yesterday for a macro that would raise the value of any given cell
by a certain percentage. I got the macro, and it worked, but if the
control
button is pushed more than once the value continues to go up. (That makes
sense). Then I found that the "Undo" stack list is cleared when you run a
macro so this presents a problem. I need to be able to "Undo" if the
control
button is pushed more than once. Also, if the cursor is inadvertantly in
any
particular cell on the spreadsheet and the button is pushed the value will
increase by the predetermined %. I would like to restrict the range to a
certain group of cells only, and within that group I can pick which cell I
want to increase the value of. I went into the EXCEL registry to increase
the
stack list number, but this still does not allow the "Undo" of a Macro.
Any advice?



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
Excel 2007 Macro [email protected] Excel Discussion (Misc queries) 2 April 17th 09 09:09 PM
help with macro in Excel 2007 Michelle Excel Discussion (Misc queries) 1 February 10th 09 03:59 AM
Excel 2007 Macro Help (Excel 2003 not working in 2007) Pman Excel Discussion (Misc queries) 4 May 29th 08 06:29 PM
Excel 2007 Macro Ken Excel Discussion (Misc queries) 1 December 8th 07 01:31 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM


All times are GMT +1. The time now is 05:17 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"