View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Test named range exists & exclude worksheet if it doesn't

I think that you have the Exit For in the wrong place. When the code reaches
the Exit For, it will immediately jump to the line of code after Next.
Therefore the Copy/Paste part of the code will never be executed.

The Exit For should be prior to the End If of the condition that you are
testing to determine if you want the code to proceed. I am not sure but it
appears that it probably should be prior to the End If where I have put the
asterisk line.

If LastRowSource + LastRowDest DestSh.Rows.Count Then
MsgBox "There are not enough rows in the Destsh"

'******************** 'Exit For maybe here.

End If

Exit For 'Code will always jump to line after Next

testRng.Copy
With DestLoc
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With

End If
End If
Next


--
Regards,

OssieMac