ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   EXCEL MACRO 2007 (https://www.excelbanter.com/excel-discussion-misc-queries/236358-excel-macro-2007-a.html)

BobF

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?

Don Guillett

EXCEL MACRO 2007
 

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?



BobF

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?




Chip Pearson

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?





All times are GMT +1. The time now is 11:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com