greenmonster15
Board Regular
- Joined
- Aug 28, 2012
- Messages
- 70
This code is looping through a range and looking for any cells that contain hyperlinks and then doing some other stuff.
I keep getting the error "Next without For" when running my loop. You'd think this would be an easy error to find. Near the bottom of the code where is reads "Next TargetRow" is the line which the error is coming up on. Help! Does it have something to do with the data type I declared my variables and the values I assigned them maybe?
I keep getting the error "Next without For" when running my loop. You'd think this would be an easy error to find. Near the bottom of the code where is reads "Next TargetRow" is the line which the error is coming up on. Help! Does it have something to do with the data type I declared my variables and the values I assigned them maybe?
Code:
'Loop Through Range Looking For Part Hyperlinks
Dim StartRow As Long
Dim EndRow As Long
Dim StartCol As Long
Dim EndCol As Long
Dim TargetRow As Long
Dim TargetCol As Long
Dim HyperCell As Range
StartRow = 20
EndRow = 50
StartCol = "E"
EndCol = "J"
HyperCell = "A100"
Cells(StartRow, StartCol).Activate
For TargetCol = StartCol To EndCol
For TargetRow = StartRow To EndRow
If ActiveCell.Hyperlinks.Count >= 1 Then
HyperCell.Value = GetAddress(ActiveCell)
strItem_Name = ActiveCell.Value
'---------Now Finding First Blank Row in Main sheet for column = 1
MainSheet.Activate
Cells(1, 1).Activate
Set Loc = Cells.Find("", ActiveCell, xlValues, xlWhole, xlByColumns)
If Not (Loc Is Nothing) Then
lngWriteRow = Loc.Row
End If
Cells(lngWriteRow, 1).Activate
Cells(lngWriteRow, lngItem_Name).Value = strItem_Name
Cells(lngWriteRow, lngItem_URL).Value = HyperCell.Value
Else
Next TargetRow
Next TargetCol