Type Mismatch Error when matching excel user profile to list of names in cells -


i getting error of type mismatch when code runs usernames = .range("a1:a100") . not sure how can fixed, suggestions?

sub addpix()  dim usernames() string dim userpixnames() string dim currentuser string dim mypassword string mypassword = "trade2013" sheets("collection slip").unprotect password:=mypassword  worksheets("user management")     'assign user names array (much faster looping through range)     usernames = .range("a1:a100")     userpixnames = .range("b1:b100") end = 1 100     'the 1 in usernames(i,1) needed because of way         'vba creates array assigned directly range         '(as did above)     if environ$("username") = usernames(i, 1)         'have missed picture inserted?         sheets("collection slip").pictures.insert _             ("g:\its\shared\signature\" & userpixnames(i, 1) & ".jpg")             .top = range("b31").top             .left = range("b31").left             .width = 250             .height = 58         end         'short-circuit loop when current user's name found         = 100     end if  next  'sheets("collection slip").protect password:=mypassword end sub 

in addition have tired dim usernames() variant instead of string. error of "type mismatch" still occurs @ 'usernames = .range("a1:a100")

any appreciated

you should dim usernames() variant instead of as string. array of values range default type variant.


Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -