Thread: Macro problem
View Single Post
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Try this as a first shot

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Address = "$Y$3" Then
If .Value = "1" Then
Macro1
End If
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

Sub Macro1()
For Each c In Worksheets("Sheet1").Range("T5:T10").Cells
On Error Resume Next
c.Hyperlinks(1).Follow NewWindow:=False, _
AddHistory:=True
Next
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Frazer" wrote in message
...
Im not too great at macro code, so if anyone could answer a few of the
problems i have with this it would be great....

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If Address = "$Y$3" Then
If Value = "1" Then
Sub Macro1()
Dim cnt As Integer
cnt = 1

For Each c In Worksheets("Sheet1").Range("T5:T10").Cells
Range("T" & cnt).Select
On Error Resume Next
Selection.Hyperlinks(1).Follow NewWindow:=False,
AddHistory:=True
cnt = cnt + 1
Next
End Sub



What this is supposed to do is select a hyperlink in a cell when the macro
is run, based on the value of another number, ie in this case the macro
should only run if the value of cell y3 is 1

The main problem with this is that it doesnt actually recognise the value

in
the cell y3, it just runs regardless of the value, so i guess there must

be
something wrong there....

Also, the actual macro I am trying to run is from the sub macro1 part

down-
it selects hyperlinks in a range of cells and opens them

However, the range part does not work unless i start in cell T1, which i

do
not want to do, i need a range from say T5:T10, but in that case it would
only do T1:T5 for some reason

can anyone help???

thnx