excel - How to Use Specified Ranges in Search Equations in VBA -



excel - How to Use Specified Ranges in Search Equations in VBA -

i trying utilize countif statement locate matches in 2 criterion on separate excel sheets within vba code. if countif statement returns value other 0, code pull row in separate sheet. however, coding hard because row changing length , row location based on amount of raw info code pulls on given day.

to clarify code below, i'll explain trying split value located in sheet named "lever arm" value located in sheet named "shop average calc" , set resulting reply in sheet named "sheet3". however, want split values if titles in row 1 , 2 match 1 another, i.e. split 'lever arm'!b3 'shop average calc'!b107 (could b107 b200 depending on day), 'lever arm'!b1 , 'lever arm'!b2 must match 'shop average calc'!b1 , 'shop average calc'!b2.

i have matched columns of info using code below, never rows.

range("b3") = "=if(countifs('daily raw data'!$d$2:$d$" & dailylastrow & ",b$1,'daily raw data'!$f$2:$f$" & dailylastrow & ",b$2,'daily raw data'!$b$2:$b$" & dailylastrow & ",$a3)=0,0,((averageifs('daily raw data'!$q$2:$q$" & dailylastrow & ",'daily raw data'!$d$2:$d$" & dailylastrow & ",b$1,'daily raw data'!$f$2:$f$" & dailylastrow & ",b$2,'daily raw data'!$b$2:$b$" & dailylastrow & ",$a3))))"

as can see, code outputs in b3 average of of points in column q matching criterion. not hard code, however, vba tricky when switching rows , using varying lastly row.

let me know if need farther clarification, effort @ equation. know wrong thought i'd seek show thought process.

sheets("lever arm").select range("c2").end(xltoright).select lastcolumn = activecell.column range("a1048576").end(xlup).select lastrow = activecell.row sheets("shop average calc").select range("a1048576").end(xlup).select shopavlastrow = activecell.row range("b2").end(xltoright).select shopavlastcolumn = activecell.column sheets("sheet3").select range("b3") = "=if(countifs('shop average calc'!range(cells(1,2),cells(1, shopavlastcolumn)),'lever arm'!b$1, 'shop average calc'!range(cells(2,2),cells(2, shopavlastcolumn)), 'lever arm'!b$2)=0, 0 , 'lever arm'!b3/'shop average calc'!range(cells(lastrow,2),cells(lastrow,lastcolumn)))"

excel vba excel-vba

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -