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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,812
Messages
5,833,801
Members
430,233
Latest member
cbutts

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top