G
Guest
Hi, Below is my poor attempt of copying a range (invoices) to another page.
The idea is:- the macro changes a number (from 1) copies a range onto
another sheet, then changes the number 1 to 2 (reformulates) copies the same
range and places beneath the last data. I want it to keep doing this until it
reaches 60 then stops.
Can someone please help and correct the code for me?
John
Sub Macro2()
Application.ScreenUpdating = False
Sheets("Delivery Note").Select
' On the worksheet this cell will say Stop when another number reaches a
certain number
Range("R5").Select
Do Until ActiveCell.Text = "Stop"
' Cell L3 increments by 1 using the next bit of code
Range("L3").Select
Selection.Copy
Range("R3").Select
Selection.PasteSpecial Paste:=xlPasteValues
' The next piece is to wait for the formula's to catch up
Application.Wait Now + TimeValue("00:00:01")
Range("S2").Select
If ActiveCell = 1 Then
Range("R2").Select
If ActiveCell = 1 Then
Application.Goto Reference:="inv_a"
Selection.Copy
Sheets("Inv").Select
iFreeRow = Cells(Rows.count, "B").End(xlUp).Row
Cells(iFreeRow + 1, "B").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Delivery Note").Select
End If
If ActiveCell = 2 Then
Application.Goto Reference:="inv_b"
Selection.Copy
Sheets("Inv (2)").Select
iFreeRow = Cells(Rows.count, "B").End(xlUp).Row
Cells(iFreeRow + 1, "B").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Delivery Note").Select
End If
End Sub
The idea is:- the macro changes a number (from 1) copies a range onto
another sheet, then changes the number 1 to 2 (reformulates) copies the same
range and places beneath the last data. I want it to keep doing this until it
reaches 60 then stops.
Can someone please help and correct the code for me?
John
Sub Macro2()
Application.ScreenUpdating = False
Sheets("Delivery Note").Select
' On the worksheet this cell will say Stop when another number reaches a
certain number
Range("R5").Select
Do Until ActiveCell.Text = "Stop"
' Cell L3 increments by 1 using the next bit of code
Range("L3").Select
Selection.Copy
Range("R3").Select
Selection.PasteSpecial Paste:=xlPasteValues
' The next piece is to wait for the formula's to catch up
Application.Wait Now + TimeValue("00:00:01")
Range("S2").Select
If ActiveCell = 1 Then
Range("R2").Select
If ActiveCell = 1 Then
Application.Goto Reference:="inv_a"
Selection.Copy
Sheets("Inv").Select
iFreeRow = Cells(Rows.count, "B").End(xlUp).Row
Cells(iFreeRow + 1, "B").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Delivery Note").Select
End If
If ActiveCell = 2 Then
Application.Goto Reference:="inv_b"
Selection.Copy
Sheets("Inv (2)").Select
iFreeRow = Cells(Rows.count, "B").End(xlUp).Row
Cells(iFreeRow + 1, "B").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Delivery Note").Select
End If
End Sub