VBA Event

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

In my entire workbook, I want to be able to change of the font of a cell when
the cell has a hyperlink in it.
This VB works if you paste it in each worksheet:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Hyperlinks.Count = 1 Then Target.Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With


End Sub


but instead of pasting 100+ worksheets in the workbook, where should I place
this code?
 
Steve,

The workbook-sheet change applies to all sheets.

Alt+F11 to open VB editor. Double click 'This workbook' and paste this in on
the right

Note I've commented out .tintshade because that doesn't work in 2003 in fact
i'm only assuming it works in another version, I've never heard of it

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Hyperlinks.Count = 1 Then Target.Select
With Selection.Font
.Color = -16776961
'.TintAndShade = 0
End With
End Sub

Mike
 

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