I have Sheet1 with Column A being a list of all US ZipCodes.
Sheet2 has Column A listing out only the zipcodes where we have sales and Column B has the amount of sales in that zip code.
Ideally, here's what I want it to do:
I want it to select A2 on Sheet1
Search for that term on Sheet2
If it doesn't exist on Sheet2, place a "0" in B2, then automatically move on to A3 and continue the process
If it does exist in Column A on Sheet 2 - select the cell to the right of the result (Column B)
Then paste that cell's contents in B2 on Sheet 1
Then continue until ALL of column A on Sheet1 has been searched for on Sheet2.
I have tried tons of macros, but they don't seem to work because not all of the zip codes in Column A Sheet1 exist in Sheet2...
Here's one the one I've been using... it only works for about 5 lines before it comes up with an error... ANY HELP would be greatly appreciated. It's frustrating not being able to figure it out :/ I really don't want the MsgBox to pop up at all...
Sub abc()
'
' abc Macro
'
'Keyboard Shortcut: Ctrl+b
Do Until IsEmpty(ActiveCell)
Dim MyString As String
MyString = ActiveCell
Sheets("Sheet2").Select
Set RangeObj = Cells.Find(What:=MyString, After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If RangeObj Is Nothing Then MsgBox "Not Found" Else: RangeObj.Select
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(-1, -1).Select
Loop
End Sub
Please let me know what I'm doing wrong
Sheet2 has Column A listing out only the zipcodes where we have sales and Column B has the amount of sales in that zip code.
Ideally, here's what I want it to do:
I want it to select A2 on Sheet1
Search for that term on Sheet2
If it doesn't exist on Sheet2, place a "0" in B2, then automatically move on to A3 and continue the process
If it does exist in Column A on Sheet 2 - select the cell to the right of the result (Column B)
Then paste that cell's contents in B2 on Sheet 1
Then continue until ALL of column A on Sheet1 has been searched for on Sheet2.
I have tried tons of macros, but they don't seem to work because not all of the zip codes in Column A Sheet1 exist in Sheet2...
Here's one the one I've been using... it only works for about 5 lines before it comes up with an error... ANY HELP would be greatly appreciated. It's frustrating not being able to figure it out :/ I really don't want the MsgBox to pop up at all...
Sub abc()
'
' abc Macro
'
'Keyboard Shortcut: Ctrl+b
Do Until IsEmpty(ActiveCell)
Dim MyString As String
MyString = ActiveCell
Sheets("Sheet2").Select
Set RangeObj = Cells.Find(What:=MyString, After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If RangeObj Is Nothing Then MsgBox "Not Found" Else: RangeObj.Select
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(-1, -1).Select
Loop
End Sub
Please let me know what I'm doing wrong