excel - Compile Error - Variable Required-can't assign to this expression -


here's code i'm replicating:

private sub btnrefresh_click()     dim w worksheet: set w = activesheet     dim last integer:  last = w.range("a100").end(xlup).row     if last = 1 exit sub     dim symbols string     dim integer     = 2 last         symbols = symbols & w.range("a" & i).value & "+"     next     symbols = left(symbols, len(symbols - 1))     debug.print last      debug.print symbols end sub 

i'm pretty sure issue in third line. had written

dim last integer: set last = w.rang("a100").end(xlup).row 

i realized set objects , removed it. receive error message:

compile error. variable required-cannot assign expression.

any idea on wrong?

it's line:

symbols = left(symbols, len(symbols - 1)) 

you're trying subtract number string. think should be

symbols = left(symbols, len(symbols) - 1) 

to subtract length of symbols when compile error it'll highlight line error on. in case highlighted minus sign.


Comments