bamaisgreat
Well-known Member
- Joined
- Jan 23, 2012
- Messages
- 831
- Office Version
- 365
- Platform
- Windows
I would like it when a cell is selected it will make the text Bold and when you click it again it makes it back to normal ??
Sorry about that I had email to popup and though that was the only post. It is a little different that I was hoping. I was needing the text to stay bold and if you went back and selected it again it would go back to normal. I guess selecting the cell would be like a switch. I didn't explain it that way originally.Try using the revised code I posted in Message #7 as I think it addresses that issue (be sure to read Message #5 to make sure you have all the right code installed). For future consideration... you should read all the messages before using the solution from any one of them so that you can see correction that were posted later on.
You cannot do that with a simple selection... once a cell is selected, "selecting" it again raises no events (Excel does nothing because it is already selected). We can do what you want if you are willing to use a double-click to toggle the bold on and off. Put this, and only this (get rid of the other codes we posted here), in the worksheet's code module...Sorry about that I had email to popup and though that was the only post. It is a little different that I was hoping. I was needing the text to stay bold and if you went back and selected it again it would go back to normal. I guess selecting the cell would be like a switch. I didn't explain it that way originally.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.Font.Bold = Not Target.Font.Bold
Cancel = True
End Sub
Good point. I'd think it will extend to workbook open / close cases as well. bamaisgreat, you may think of some other event like Double Click so as to have control over font change.One possible minor problem with it... select a cell on the managed sheet, then select another sheet, then activate the "Go To" dialog box (ALT+EG) and type a reference back to the managed sheet to a cell different than the one that was selected when you switched sheets... both the previously selected and newly selected cells will both be highlighted.
Good point. I'd think it will extend to workbook open / close cases as well. bamaisgreat, you may think of some other event like Double Click so as to have control over font change.
Thank you that is awesome .. so lets say I wanted it to change the color of the font to red and make it bold ??? How would that need to look ?You cannot do that with a simple selection... once a cell is selected, "selecting" it again raises no events (Excel does nothing because it is already selected). We can do what you want if you are willing to use a double-click to toggle the bold on and off. Put this, and only this (get rid of the other codes we posted here), in the worksheet's code module...
Code:Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Target.Font.Bold = Not Target.Font.Bold Cancel = True End Sub
Try it like this...Thank you that is awesome .. so lets say I wanted it to change the color of the font to red and make it bold ??? How would that need to look ?
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.Font.Bold = Not Target.Font.Bold
Cancel = True
End
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Font.Bold = Not Target.Font.Bold
Target.Font.ColorIndex = -4102 - Target.Font.ColorIndex
End Sub