ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle Macro (https://www.excelbanter.com/excel-programming/301184-toggle-macro.html)

Michael

Toggle Macro
 
I'm having trouble learning Macros. I need to toggle a single cell (d33) between a value of 8% and blank.

ALSO, I'd love a better site for help topic. MS really dropped the ball on this topic.

Thanks,
Michael
---

Bernie Deitrick

Toggle Macro
 
Michael,

Sub ToggleD33()
If Range("D33").Value = "" Then
Range("D33").Value = 0.08
Else
Range("D33").ClearContents
End If
End Sub

HTH,
Bernie
MS Excel MVP

"Michael" wrote in message
...
I'm having trouble learning Macros. I need to toggle a single cell (d33)

between a value of 8% and blank.

ALSO, I'd love a better site for help topic. MS really dropped the ball

on this topic.

Thanks,
Michael
---




Tom Ogilvy

Toggle Macro
 
Sub ToggleCell()
if isempty(Range("D33")) then
Range("D33").value = .08
Range("D33").Numberformat = "0%"
Else
Range("D33").ClearContents
End If
End Sub

--
Regards,
Tom Ogilvy


"Michael" wrote in message
...
I'm having trouble learning Macros. I need to toggle a single cell (d33)

between a value of 8% and blank.

ALSO, I'd love a better site for help topic. MS really dropped the ball

on this topic.

Thanks,
Michael
---




JulieD

Toggle Macro
 
Hi Michael

i would do it using:

Sub togglevalue()
If Sheets("Sheet1").Range("D33").Value = "" Then
Sheets("Sheet1").Range("D33").Value = 0.08
Else
Sheets("Sheet1").Range("D33").Value = ""
End If
End Sub

and format the cell to percentage
you can assign this code to a button / toolbar icon or shortcut key as you
wish

Hope this helps
Cheers
JulieD



"Michael" wrote in message
...
I'm having trouble learning Macros. I need to toggle a single cell (d33)

between a value of 8% and blank.

ALSO, I'd love a better site for help topic. MS really dropped the ball

on this topic.

Thanks,
Michael
---




Frank Kabel

Toggle Macro
 
Hi
see: http://www.mvps.org/dmcritchie/excel/getstarted.htm

maybe something like
sub foo()
with activesheet.range("D33")
if .value="" then
.value = 0.08
else
.value=""
end if
end with
end sub



--
Regards
Frank Kabel
Frankfurt, Germany


Michael wrote:
I'm having trouble learning Macros. I need to toggle a single cell
(d33) between a value of 8% and blank.

ALSO, I'd love a better site for help topic. MS really dropped the
ball on this topic.

Thanks,
Michael
---


Bob Phillips[_6_]

Toggle Macro
 
Tom was the only one to give you the format as well, but the code

Range("D33").value = .08
Range("D33").Numberformat = "0%"

can be combined with

Range("D33").value = "8%"

Excel does the rest.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Michael" wrote in message
...
I'm having trouble learning Macros. I need to toggle a single cell (d33)

between a value of 8% and blank.

ALSO, I'd love a better site for help topic. MS really dropped the ball

on this topic.

Thanks,
Michael
---





All times are GMT +1. The time now is 07:46 PM.

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