briankimberly
New Member
- Joined
- Nov 14, 2013
- Messages
- 42
for some reason the code works correctly (moving down to new row in a range B2 is the header and goes to B15) the first time through, but then when i try to loop it again instead of starting on the first "LOI" (B3) it skips the first row and moves the second (B4)? any thoughts on way that would be the case?
Sheets("Main Cal").Select
Dim bottomA As Integer
bottomA = Range("B" & Rows.Count).End(xlUp).Row
Dim LOI As Range
Dim ws As Worksheet
For Each LOI In Range("B3:B" & bottomA)
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(LOI.Value)
On Error GoTo 0
If ws Is Nothing Then
Sheets("Main Cal").Select
LOI.Select
Selection.Copy
Selection.Offset(0, 7).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next LOI
Sheets("Main Cal").Select
Dim bottomA As Integer
bottomA = Range("B" & Rows.Count).End(xlUp).Row
Dim LOI As Range
Dim ws As Worksheet
For Each LOI In Range("B3:B" & bottomA)
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(LOI.Value)
On Error GoTo 0
If ws Is Nothing Then
Sheets("Main Cal").Select
LOI.Select
Selection.Copy
Selection.Offset(0, 7).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next LOI