To start I am a noob. I literally just looked a VBA for the first time yesterday. So I appreciate if you dumb up your replies. lol.
A couple times a week I am given a spread sheet at work. I have to split the zip codes and move them to there perspective Store. There is about 20 zip codes and although I use the sort option, It still takes me awhile. I want to use the marco to pretty much give each zipcode a store.
Here is my issue. I am trying to look at "J1" if the zip code matches one of many I want "Bullhead" to be written in "M1"
I was able to do this, It took me several hours of trial and error to come up with the best result. I tried a lot of different things. (At the very bottom is what I came up with)
Here is the problem. I need to do this all the way down the spread Sheet. ie. if J3 = 86409 M3 = Kingman. If J4 = 86409 M4 = Kingman. So on and so on all the way to J5000,M5000.
Any help would be greatly appreciated. What I want to do is simple but I could not find the answer on my own, or I could not understand it. I assume I will have to start over. And take a different approach. Not sure what though.
Sub MoversBirthdays()
Dim zipcode As Long, Store As String
zipcode = Range("J2").Value
If zipcode = "86426" Or "86427" Or "86429" Or "86430" Or "86435" Or "86436" Or "86437" Or "86438" Or "86439" Or "86440" Or "86442" Or "86446" Or "89028" Or "89029" Or "89046" Or "92304" Or "92332" Or "92363" Then Store = "Bullhead" Else: Store = "Kingman"
If zipcode = "" Then Store = ""
Range("M2").Value = Store
End Sub
A couple times a week I am given a spread sheet at work. I have to split the zip codes and move them to there perspective Store. There is about 20 zip codes and although I use the sort option, It still takes me awhile. I want to use the marco to pretty much give each zipcode a store.
Here is my issue. I am trying to look at "J1" if the zip code matches one of many I want "Bullhead" to be written in "M1"
I was able to do this, It took me several hours of trial and error to come up with the best result. I tried a lot of different things. (At the very bottom is what I came up with)
Here is the problem. I need to do this all the way down the spread Sheet. ie. if J3 = 86409 M3 = Kingman. If J4 = 86409 M4 = Kingman. So on and so on all the way to J5000,M5000.
Any help would be greatly appreciated. What I want to do is simple but I could not find the answer on my own, or I could not understand it. I assume I will have to start over. And take a different approach. Not sure what though.
Sub MoversBirthdays()
Dim zipcode As Long, Store As String
zipcode = Range("J2").Value
If zipcode = "86426" Or "86427" Or "86429" Or "86430" Or "86435" Or "86436" Or "86437" Or "86438" Or "86439" Or "86440" Or "86442" Or "86446" Or "89028" Or "89029" Or "89046" Or "92304" Or "92332" Or "92363" Then Store = "Bullhead" Else: Store = "Kingman"
If zipcode = "" Then Store = ""
Range("M2").Value = Store
End Sub
Last edited: