I'm a novice to VBA and I'm trying to make a simple macro where one can highlight a set of cells, click a button, and strikethrough the selected sells. After, you can select the cell again, click the same button, and remove the strikethrough.
I have been looking for decent documentation but, have yet to find anything.
Here's some code.
Also, I would love to know where the best documentation is on VBA.
Sub strikeOut()
Selection.Font.Strikethrough = True
End Sub
I also need help with the command button.
Thank you.
It looks like you're on the right path. Based on your code, I'm assuming you already have a command button created. If so try this:
Sub strikeOut()
With Selection.Font
.Strikethrough = Not .Strikethrough
End With
End Sub
To create a command button:
Visual Basic toolbar and activate the Control Toolbox button. Another box/toolbar should appear with different control options. Button option and place it in the desired location. Developer tab/ribbon. Insert and select Button and place it in the desired location.Properties to give your button a name/caption.View Code.ButtonName_Click() sub, add the strikeOut() call using either:
Call strikeOut()strikeOutTo answer the second part of your question, it's hard to say what is the 'best' but here are some links that may help:
Chip Pearson's site
MSDN
OZgrid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With