skipping blank cells in vba for converting hyperlinks to text address

lindesswhy

New Member
Joined
Jul 29, 2014
Messages
5
this is the code i have so far for converting my "Email" hyperlinks all in column G into the actual email address text.

Sub AAshowHyperlink()

Range("G1").Activate

Do Until IsEmpty(ActiveCell)
If ActiveCell.Hyperlinks.Count <> 0 Then
ActiveCell.Value = Replace(ActiveCell.Hyperlinks.Item(1).Address, "mailto:", "")
End If
ActiveCell.Offset(1, 0).Activate
Loop

End Sub

I would like to know what line I can add to make it so that it skips blank cells in column G. Not everyone in my worksheet has an email listed.

Thanks!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Maybe:
Sub AAshowHyperlink()
Dim lR as long
lR = Range("G" & Rows.Count).End(xlUp).Row
Range("G1").Activate

Do Until Activecell.Row > lR
If Not Isempty(Activecell) Then
If ActiveCell.Hyperlinks.Count <> 0 Then
ActiveCell.Value = Replace(ActiveCell.Hyperlinks.Item(1).Address, "mailto:", "")
End If
End If
ActiveCell.Offset(1, 0).Activate
Loop

End Sub
 
Upvote 0
thank you so much! im still pretty new to excel VBA so i don't understand everything in the new line of formula but it is working so far, i really appreciate your help! you have saved me a ton of time!

EXCEL RULES!
 
Upvote 0

Forum statistics

Threads
1,215,657
Messages
6,126,057
Members
449,284
Latest member
fULMIEX

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