Hello.
Open to suggestions on how to best accomplish the following. Thanks in advance to anyone who can help:
I'm working on an excel macro that compares the value in a cell against the value in another series of cells in another column.
If there is a match, then there is a copy paste done of cells in that same row and it's pasted to a worksheetname that matches the value of another cell in that row.
I have the part about worksheet name (thanks to a helpful member in this forum). What I am now looking for is a way to run through the comparisons with a for next instead of a very long set of if/then statements
Below are the first 3 if then statements (there's over 100 rows/comparisons that need to be done).
......![]()
If Range("B2").Value = Range("AD2").Value Then Range("d2:e2").Select Selection.Copy addr = Sheets("Actual_Export").Range("AC2") Sheets(addr).Select Range("a1").Select ActiveSheet.Paste Else If Range("B2").Value = Range("AD3").Value Then Range("d2:e2").Select Selection.Copy addr = Sheets("Actual_Export").Range("AC3") Sheets(addr).Select Range("a1").Select ActiveSheet.Paste Else If Range("B2").Value = Range("AD4").Value Then Range("d2:e2").Select Selection.Copy addr = Sheets("Actual_Export").Range("AC4") Sheets(addr).Select Range("a1").Select ActiveSheet.Paste
Also, after running through that if/else statement above 100 times (comparing a2 to ad2 thru ad 101), it then needs to run similar if/else satements
for row 3 100 times (coparing a3 to ad2 to ad101), like below.
So not sure if there's a way to accomplish both of these comparisons in one for next loop or if it needs to be 2 separate for next loops.
----![]()
If Range("B3").Value = Range("AD2").Value Then Range("a3:d3").Select Selection.Copy addr = Sheets("Actual_Export").Range("AC2") Sheets(addr).Select Range("a1").Select ActiveSheet.Paste Else If Range("B3").Value = Range("AD3").Value Then Range("d3:e3").Select Selection.Copy addr = Sheets("Actual_Export").Range("AC3") Sheets(addr).Select Range("a1").Select ActiveSheet.Paste Else If Range("B3").Value = Range("AD4").Value Then Range("d3:e3").Select Selection.Copy addr = Sheets("Actual_Export").Range("AC4") Sheets(addr).Select Range("a1").Select ActiveSheet.Paste
Thanks to anyone who has read through all this and extra thanks to anyone who can help.![]()
Bookmarks