excel - Using two array's in one application with progressing the arrays -
i have below code i'm trying put , i'm running run-time error '9' subscript out of range. work through first run through errors. don't see why won't allow string go forward. i'm reading should go through application changing x values y value 1 , when completed set go next y , start whole process again until end of y. appreciated.
dim cat(1 10) string cat(1) = "010" 'sd cat(2) = "020" 'fd cat(3) = "050" 'wvid cat(4) = "040" 'vid cat(5) = "030" 'mem cat(6) = "080" 'acc cat(7) = "060" 'hdmi cat(8) = "070" 'ssd cat(9) = "090" 'power cat(10) = "990" 'zrm dim month(1 12) string month(1) = "january" month(2) = "february" month(3) = "march" month(4) = "april" month(5) = "may" month(6) = "june" month(7) = "july" month(8) = "august" month(9) = "september" month(10) = "october" month(11) = "november" month(12) = "december" y = 1 ubound(cat) x = 1 ubound(month) month(x) = application.worksheetfunction.sumif(sheets(month(x)).columns("ao"), cat(y), sheets(month(x)).columns("ag")) next x cells(3 + y, 41).value = application.worksheetfunction.sum(month(1), month(2), month(3), month(4), month(5), month(6), month(7), month(8), month(9), month(10), month(11), month(12)) next y end sub
on first run through loop indexed x computing conditional sum of data stored in sheet "january". , overwriting "january" value in month(x). let's that value 42. on next run through loop 42 in month(x) looking sheets(42), isn't valid worksheet. try instead.
dim temp double y = 1 ubound(cat) temp = 0# '0 double. x = 1 ubound(month) temp = temp + application.worksheetfunction.sumif(sheets(month(x)).columns("ao"), cat(y), sheets(month(x)).columns("ag")) next x cells(3 + y, 41).value = temp next y this way don't need store of sums each sheet, since use them add them together.
Comments
Post a Comment