excel - VBA Range and String confusion -


think i'm having problem difference between ranges , strings. trying search cells in range of winners spit out point value.

sub it() dim round1 range dim round2 range dim lngcnt long dim winner() string dim pointsum double redim winner(1 4)     winner(1) = "mohler"     winner(2) = "scotter"     winner(3) = "dkgay"     winner(4) = "lassie" set round1 = range("l3,l11,l22,l32").text each winner in round1 lngcnt = lngcnt + 10 winner(lngcnt) = pointsum.value next msgbox pointsum.value     end sub 

you need 2 loops:

sub it() dim round1 range dim round2 range dim lngcnt long dim winner() string dim pointsum double dim rng range dim long redim winner(1 4)     winner(1) = "mohler"     winner(2) = "scotter"     winner(3) = "dkgay"     winner(4) = "lassie" set round1 = range("l3,l11,l22,l32") each rng in round1     = 1 ubound(winner)         if rng.value = winner(i)             pointsum = pointsum + 10             exit         end if     next next rng  msgbox pointsum.value end sub 

the first loops through ranges second through string array. when finds equal adds 10.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -