Code:
wb2.ActivateSheets("Invoice").Activate
For Each cell In Worksheets("Invoice").Range("A37,A45,A53")
If cell.Value = "OK" Then
wb2.Activate
Sheets("Invoice").Activate
Range("B3").Copy
wb1.Activate
Sheets("General Ledger").Activate
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
Sheets("OK").Activate
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
wb2.Activate
Sheets("Invoice").Activate
ActiveCell.Copy
wb1.Activate
Sheets("General Ledger").Activate
Range("A1").End(xlDown).Offset(0, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Sheets("OK").Activate
Range("A1").End(xlDown).Offset(0, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
wb2.Activate
Sheets("Invoice").Activate
ActiveCell.Offset(0, 4).Copy
wb1.Activate
Sheets("General Ledger").Activate
Range("A1").End(xlDown).Offset(0, 58).Select
Selection.PasteSpecial Paste:=xlPasteValues
Sheets("OK").Activate
Range("A1").End(xlDown).Offset(0, 4).Select
Selection.PasteSpecial Paste:=xlPasteValues
This is part of a loop that is intended to loop for the three cells specified in line
Code:
For Each cell In Worksheets("Invoice").Range("A37,A45,A53")
I am concerned that after the initial part of the script:
Code:
wb2.ActivateSheets("Invoice").Activate
Range("B3").Copy
wb1.Activate
Sheets("General Ledger").Activate
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
Sheets("OK").Activate
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
the activecell will be different from the cell that is the subject of the loop (A37,A45,or A53) which I would like to use as the basis for the next several steps in the loop.
There are two other If - Then lines with basically the same script in between
How do I select the correct cell (A37, A45, or A53) as the activecell on "invoice" sheet if I have already selected a cell earlier in the script? Ideas?