AnilPullagura
Board Regular
- Joined
- Nov 19, 2010
- Messages
- 98
Hey Pros,
Need a help for the below scenario:
I have a spreadsheet which has zip codes in Column J. I also have sheets named with Zip Codes.
I need a macro that checks the Zipcode in cell J2 of Sheet1, matches the corresponding sheetname, then copies entire row from Sheet1 for that zip code and pastes them to the corresponding sheet.
There are more than one entry for a zipcode in Sheet1. So all the rows matching the Zipcode to SheetName should be copied.
I did try to write, but was unable to write for the Range of values. However if I hardcode for a single zipcode, the below code works.
Can i get any help in for the entire range of J2:J1385 of Sheet1
Below is my code which works for hard coded zip code of 21216.
Thanks,
Anil
Need a help for the below scenario:
I have a spreadsheet which has zip codes in Column J. I also have sheets named with Zip Codes.
I need a macro that checks the Zipcode in cell J2 of Sheet1, matches the corresponding sheetname, then copies entire row from Sheet1 for that zip code and pastes them to the corresponding sheet.
There are more than one entry for a zipcode in Sheet1. So all the rows matching the Zipcode to SheetName should be copied.
I did try to write, but was unable to write for the Range of values. However if I hardcode for a single zipcode, the below code works.
Can i get any help in for the entire range of J2:J1385 of Sheet1
Below is my code which works for hard coded zip code of 21216.
Code:
Sub CpyToMultipleSheets()
Set i = Sheets("Sheet1")
Set e = Sheets("21216")
Dim d
Dim j
d = 1
j = 2
Do Until IsEmpty(i.Range("J" & j))
If i.Range("J" & j) = "21216" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
End Sub
Anil