Toggle Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
---
 
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 said:
I'm having trouble learning Macros. I need to toggle a single cell (d33)
between a value of 8% and blank.
 
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 said:
I'm having trouble learning Macros. I need to toggle a single cell (d33)
between a value of 8% and blank.
 
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 said:
I'm having trouble learning Macros. I need to toggle a single cell (d33)
between a value of 8% and blank.
 
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 said:
I'm having trouble learning Macros. I need to toggle a single cell (d33)
between a value of 8% and blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top