Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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 |
#2
![]() |
|||
|
|||
![]()
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 |
#3
![]() |
|||
|
|||
![]()
Hey, thanks again bob, but something is still not right
The problem with the range has been solved, so thanks for that, but still not the value part, it seems to make no difference whether the value is 0 or 1, the macro still runs and selects the hyperlinks.... "Bob Phillips" wrote: 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 |
#4
![]() |
|||
|
|||
![]()
no worries got it now cheers!!
"Frazer" wrote: Hey, thanks again bob, but something is still not right The problem with the range has been solved, so thanks for that, but still not the value part, it seems to make no difference whether the value is 0 or 1, the macro still runs and selects the hyperlinks.... "Bob Phillips" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
deleting a macro resulted in a problem | Excel Discussion (Misc queries) | |||
Circular Problem needs Macro | Excel Discussion (Misc queries) | |||
External data Macro Problem Excel 97 | Excel Discussion (Misc queries) | |||
Problem executing a macro from different workbook where it is | Excel Discussion (Misc queries) | |||
macro problem | Excel Discussion (Misc queries) |