Help Updating URL Checking Code to Skip Cells and Add Text if Missing a URL

CatLadee

New Member
Joined
Sep 7, 2018
Messages
29
Hoping for a little help with the updates to this code indicated below. Really appreciate your time and input and sending the most positive karma your way! - The Cat Ladee


Sub ValidateURLs()


Dim Cell As Range
Dim Rng As Range
Dim RngEnd As Range
Dim Status As String
Dim Wks As Worksheet

Set Wks = ActiveSheet
Set Rng = Wks.Range("F2")

Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = Wks.Range(Rng, RngEnd)

For Each Cell In Rng 'EXCEPT BLANK CELLS, CELLS CONTAINING THE TEXT "mailto:", AND THE CELL WITH "https://www.state.gov/travel/"
Status = GetURLStatus(Cell)
If (Status <> "200 - OK") And (Status <> "301 - Moved Permanently") And (Status <> "302 - Moved Temporarily") And (Status <> "401 - Unauthorized") And (Status <> "302 - Found") Then
Cell.Offset(0, 1) = Status
End If
Next Cell


'If BLANK CELLS Then Cell.Offset(0, 1) = "Missing URL"

End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Is this what you're after

Code:
Sub ValidateURLs()


Dim Cell As Range
Dim Rng As Range
Dim RngEnd As Range
Dim Status As String
Dim Wks As Worksheet

Set Wks = ActiveSheet
Set Rng = Wks.Range("F2")

Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = Wks.Range(Rng, RngEnd)

For Each Cell In Rng
    If Cell = "" Or Cell = "mailto:" Or Cell = "https://www.state.gov/travel/" Then
        Cell.Offset(0, 1) = "Missing URL"
    Else
        Status = GetURLStatus(Cell)
        If (Status <> "200 - OK") And (Status <> "301 - Moved Permanently") And (Status <> "302 - Moved Temporarily") And (Status <> "401 - Unauthorized") And (Status <> "302 - Found") Then
            Cell.Offset(0, 1) = Status
        End If
    End If
Next Cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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