#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default VBA Event

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default VBA Event

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

"Steve" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default VBA Event

Mike,

Thank you so much, it works perfect!
--
Steve


"Mike H" wrote:

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

"Steve" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
event marker68 Excel Discussion (Misc queries) 1 April 4th 08 02:38 PM
Workbook_Open() Event Bill Martin Excel Discussion (Misc queries) 9 January 13th 06 08:24 PM
Change event? Mike Rogers Excel Discussion (Misc queries) 2 January 5th 06 01:46 AM
It seems to me that I need an event Macro, nick s Excel Worksheet Functions 8 November 28th 05 05:37 PM
Event Macro stevepain Excel Discussion (Misc queries) 6 August 5th 05 05:11 AM


All times are GMT +1. The time now is 10:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"