I have written a loop to go down a range of codes one by one, copying and pasting each active cell into another worksheet, printing that worksheet and repeating the process for the next code down in the list theoretically until the bottom cell which contains the word END, where I want my macro to stop.
Despite my variable being assigned and in VBA showing that it recognises the value to be "END" when the active cell reaches the bottom cell the macro is not stopping and carries on going into the blank cells.
Can anybody see where I've gone wrong? As far as I can see I've assigned the variables and given a condition for the loop to stop and am at a loss to why the thing keeps going once it reached the "END" cell.
Code below, any advice or thoughts greatly appreciated.
Sub PrintISINPage()
Dim myWorkbook As Workbook
Dim wsISINList As Worksheet
Dim wsISINToPrint As Worksheet
Dim ISINPrint As Range
Dim myCommand As String
Set myWorkbook = ActiveWorkbook
Set wsISINList = Sheets("ISINList")
Set wsISINToPrint = Sheets("ISINToPrint")
Set ISINPrint = Range("ISINPrint")
myCommand = ActiveCell.Value()
wsISINList.Select
Range("A1").Select
Selection.Copy
wsISINToPrint.Select
ISINPrint.Select
Selection.PasteSpecial Paste:=xlAll
wsISINToPrint.PrintOut
Sheets("ISINList").Select
Do Until myCommand = "END"
wsISINList.Select
ActiveCell.Offset(1).Activate
Selection.Copy
wsISINToPrint.Select
ISINPrint.Select
Selection.PasteSpecial Paste:=xlAll
wsISINToPrint.PrintOut
wsISINList.Select
ActiveCell.Activate
Loop
End Sub
Bookmarks