vba - Run Time error 13: Type Mismatch on code when I add certain lines of code -


so code working fine until tried add nested loop , started getting run time error 13. line error is surrounded ***

this code before working:

dim lr long dim colltr string dim ave double dim stdev double  = 1 datetime_column  colltr = replace(cells(1, i).address(true, false), "$1", "")     ave = application.average(range(colltr & "1:" & colltr & lr)) ' based on     values     stdev = application.stdev(range(colltr & "1:" & colltr & lr)) ' based on     values  next 

and here code after gets error:

dim lr long dim colltr string dim ave double dim stdev double dim q integer redim range(lr1) variant  = 1 datetime_column  sheets(1).select  colltr = replace(cells(1, i).address(true, false), "$1", "")  ***ave = application.average(range(colltr & "2:" & colltr & lr))*** ' based on values  q = 1 lr1 range(q) = worksheetfunction.abs(cells(q + 1, colltr) - cells(q, colltr)) next q 

next i

my original thought lr long tried changing string data type didn't work either, maybe has loop?

it's never idea repurpose name of range object other intended be. in case you've decided allow activesheet property default range.parent property while redefining range.

dim lr long, lr1 long, q long dim ave double, stdev double redim vals(lr1) variant   sheets(1)     = 1 datetime_column         lr = .cells(.rows.count, i).end(xlup).row          ave = application.average(.range(.cells(2, i), .cells(lr, i))) ' based on values          q = 1 lr1             vals(q) = worksheetfunction.abs(.cells(q + 1, i) - .cells(q, i))         next q     next end 

i removed whole colltr business , explicitly provided range.parent property of range , .cells objects.

you still need vals array , make sure lr1 defined.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -