I tried to make a macro that searches a table for a record with a certain value, and when it does find it, an inner loop then searches another table and changes a value offset from it.
The thing is, i cannot work out how to get the loops to work.
Here is the code:
Sub CleanOrders()
Dim Ordernumber As String
Application.ScreenUpdating = False
Sheets("Shipping and Payment").Select
Range("F9").Select
Do Until ActiveCell = ""
If ActiveCell = ActiveSheet.Range("y6") Then
ActiveCell.Offset(0, -4).Select
Ordernumber = ActiveCell.Value
Selection.EntireRow.Delete
Sheets("Invoice records").Select
Range("A4").Select
Do While ActiveCell <> ""
If ActiveCell.Text = Ordernumber Then
ActiveCell.Offset(26, 7).Select
ActiveCell.FormulaR1C1 = "Shipped"
GoTo 1
End If
ActiveCell.Offset(1, 0).Activate
Loop
1
Else
ActiveCell.Offset(1, 0).Select
Loop
Msgbox ("Shipped orders have been removed")
End Sub
Can anyone help?
The thing is, i cannot work out how to get the loops to work.
Here is the code:
Sub CleanOrders()
Dim Ordernumber As String
Application.ScreenUpdating = False
Sheets("Shipping and Payment").Select
Range("F9").Select
Do Until ActiveCell = ""
If ActiveCell = ActiveSheet.Range("y6") Then
ActiveCell.Offset(0, -4).Select
Ordernumber = ActiveCell.Value
Selection.EntireRow.Delete
Sheets("Invoice records").Select
Range("A4").Select
Do While ActiveCell <> ""
If ActiveCell.Text = Ordernumber Then
ActiveCell.Offset(26, 7).Select
ActiveCell.FormulaR1C1 = "Shipped"
GoTo 1
End If
ActiveCell.Offset(1, 0).Activate
Loop
1
Else
ActiveCell.Offset(1, 0).Select
Loop
Msgbox ("Shipped orders have been removed")
End Sub
Can anyone help?