How to write a VBA multi row coresponding cells If Statement in Excel -


to start noob. literally looked vba first time yesterday. appreciate if dumb replies. lol.

a couple times week given spread sheet @ work. have split zip codes , move them there perspective store. there 20 zip codes , although use sort option, still takes me awhile. want use marco pretty give each zipcode store.

here issue. trying @ "j1" if zip code matches 1 of many want "bullhead" written in "m1"

i able this, took me several hours of trial , error come best result. tried lot of different things. (at bottom came with)

here problem. need way down spread sheet. ie. if m3 = 86409 j3 = kingman. if m4 = 86409 j4 = kingman. on , on way m5000,j5000.

any appreciated. want simple not find answer on own, or not understand it. assume have start over. , take different approach. not sure though.

sub moversbirthdays()       dim zipcode long, store 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" store = "bullhead" else: store = "kingman"       if zipcode = "" store = ""       range("m2").value = store   end sub  

sub moversbirthdays()      dim varzip variant     dim arrstore() string     dim storeindex long      range("j2", cells(rows.count, "j").end(xlup))         if .row < 2 exit sub   'no data         redim arrstore(1 .rows.count)         each varzip in .value             storeindex = storeindex + 1             select case varzip                 case 86426 86427, 86429 86430, 86435 86440, 86442, 86446, 89028 89029, 89046, 92304, 92332, 92363                     arrstore(storeindex) = "bullhead"                 case ""                     arrstore(storeindex) = ""                 case else                     arrstore(storeindex) = "kingman"             end select         next varzip     end      if storeindex > 0 range("m2").resize(storeindex).value = application.transpose(arrstore)  end sub 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -