Hi,
One of the forum members gave me this piece of code to run down column A starting at A2 on a sheet called urls. It goes to the relevant url copies the data adds a sheet and pastes the data into it.
Works perfectly with one small exception if the url has been removed then it can't find anything and it stops at -
.Refresh BackgroundQuery:=False
Could anyone give me a piece of code to add so that of the url isn't found it moves onto the next? i.e. if the url in a33 can't be found it moves to a34 and so on.
Many thanks.
Sub su()
Dim val, countofhyperlink As Integer
For i = 2 To 2 ' here add the number of hyperlinks you have.
val = "a" & i ' add the hyperlinks in sheet 1
MsgBox val
v = Sheets("Sheet1").Range(val).Value
MsgBox v
vc = "URL;" & v
Sheets.Add
With ActiveSheet.QueryTables.Add(Connection:=vc, Destination _
:=Range("$A$1"))
.Name = "members.aspx?mgid= v"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """MembersGrid"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next
Bookmarks