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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
Hi Pennysaver

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

Thanks
 
Upvote 0
Not tested, but what about:
Code:
Sheets("Associate").Range("A1").Hyperlinks.delete 
Sheets("OpenReqs").Range("A1").Hyperlinks.delete 
Sheets("Contractor").Range("A1").Hyperlinks.delete
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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