#1   Report Post  
Frazer
 
Posts: n/a
Default Macro problem

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   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



  #3   Report Post  
Frazer
 
Posts: n/a
Default

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   Report Post  
Frazer
 
Posts: n/a
Default

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
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
deleting a macro resulted in a problem militant Excel Discussion (Misc queries) 0 April 26th 05 05:21 AM
Circular Problem needs Macro NICK Excel Discussion (Misc queries) 2 February 1st 05 09:09 AM
External data Macro Problem Excel 97 Craig Kelly Excel Discussion (Misc queries) 1 January 17th 05 03:17 PM
Problem executing a macro from different workbook where it is Sergio Calleja Excel Discussion (Misc queries) 1 January 17th 05 12:38 PM
macro problem Kevin Excel Discussion (Misc queries) 1 December 14th 04 10:47 PM


All times are GMT +1. The time now is 05:14 PM.

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"