ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   update variable (https://www.excelbanter.com/excel-discussion-misc-queries/18717-update-variable.html)

nc

update variable
 
Hi

How can I update a variable by a value of one each time a
command button is clicked using macros?

Thanks.

Bill Martin -- (Remove NOSPAM from address)

nc wrote:

Hi

How can I update a variable by a value of one each time a
command button is clicked using macros?

Thanks.


---------------------------------

Even easier, rather than a "button" use a "spinner". It's available to
you on the same tool bar you'd use to create a "button". It provides a
both up and down buttons to increment or decrement a cell. In the
properties for the spinner you can define the cell to link it to. No
macro required.

Good luck...

Bill

JulieD

Hi

assuming you mean a cell value by 1 something along the lines of

Sub increasevalue()
If IsNumeric(Range("A1")) Or IsNull(Range("A1")) Then _
Range("A1").Value = Range("A1").Value + 1
End Sub

if this isn't what you've after could you please explain what you mean by a
"variable"

Cheers
JulieD

"nc" wrote in message
...
Hi

How can I update a variable by a value of one each time a
command button is clicked using macros?

Thanks.




nc

Thanks JulieD.


-----Original Message-----
Hi

assuming you mean a cell value by 1 something along the

lines of

Sub increasevalue()
If IsNumeric(Range("A1")) Or IsNull(Range("A1"))

Then _
Range("A1").Value = Range("A1").Value + 1
End Sub

if this isn't what you've after could you please explain

what you mean by a
"variable"

Cheers
JulieD

"nc" wrote in

message
...
Hi

How can I update a variable by a value of one each

time a
command button is clicked using macros?

Thanks.



.



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

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