|
-
May 4th, 2013, 06:06 AM
#2
Re: VBA error 1004 Application-defined or object-defined error
pls use code tags when posting code
this should really be a SUB as it returns nothing to the caller
ActiveSheet.Hyperlinks.Add _
Anchor:=Cells(intCtr, 3), _
Address:="", _
SubAddress:="'" & Replace(ws.Name, "'", "''", 1) & "'!A1", _
TextToDisplay:=ws.Name
your problem is not using fully qualified ranges for all range object parameters, avoid using activesheet, specify the correct sheet for the target hyperlinks and specify the sheet for the range parameters of anchor
maybe like
Code:
wsMain.Hyperlinks.Add _
Anchor:=ws.Cells(intCtr, 3), _
Address:="", _
SubAddress:="'" & Replace(ws.Name, "'", "''", 1) & "'!A1", _
TextToDisplay:=ws.Name
after staring at the subaddress for a while i am still at a loss as to what you are replacing in the worksheet name
edit i can see this after posting the code within the tags
Last edited by westconn1; May 4th, 2013 at 06:13 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|