ahortened VBA code

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247
Hi

I have the following code and I was wondering if I could write a single select statement to choose the multiple sheets and single statement to remove the hyperlink.

Sheets("Associate").Select
Range("A1").Select
Application.CutCopyMode = False
Selection.Hyperlinks.delete

Sheets("OpenReqs").Select
Range("A1").Select
Application.CutCopyMode = False
Selection.Hyperlinks.delete

Sheets("Contractor").Select
Range("A1").Select
Application.CutCopyMode = False
Selection.Hyperlinks.delete

Thanks
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Something like this maybe:

<font face=tahoma><SPAN style="color:#00007F">Sub</SPAN> RemoveHyperLinks()
    <SPAN style="color:#00007F">Dim</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet
        <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets
            ws.Range("A1").Hyperlinks.Delete
        <SPAN style="color:#00007F">Next</SPAN> ws
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247
Hi Pennysaver

Thanks for a quick response, would your code delete the hyperlink in other tabs? I only want the hyper link deleted in "Associate", "OpenReqs", and "Contractor" tabs.

Thanks
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
How's this:

<font face=tahoma><SPAN style="color:#00007F">Sub</SPAN> RemoveHyperLinks()
    <SPAN style="color:#00007F">Dim</SPAN> CurSheet <SPAN style="color:#00007F">As</SPAN> Worksheet
        <SPAN style="color:#00007F">Set</SPAN> CurSheet = ActiveSheet
        
        Sheets(Array("Associates", "OpenRegs", "Contractor")).Select
        Range("A1").Hyperlinks.Delete
        CurSheet.Activate
        
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Smitty
 

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247

ADVERTISEMENT

Hi Pennysaver

This code only removes the hyperlink from the Associate tab and not the others.

Thanks
 

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
Not tested, but what about:
Code:
Sheets("Associate").Range("A1").Hyperlinks.delete 
Sheets("OpenReqs").Range("A1").Hyperlinks.delete 
Sheets("Contractor").Range("A1").Hyperlinks.delete
 

highndry

Board Regular
Joined
Nov 28, 2005
Messages
247

ADVERTISEMENT

Thanks Barrie Davidson that worked.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Sorry, that's what I get for not testing (or using hyperlinks much).

Smitty
 

Watch MrExcel Video

Forum statistics

Threads
1,118,524
Messages
5,572,640
Members
412,478
Latest member
MakeItWorkVBA
Top