excel - Searching for a case-sensitive VBA version of sumproduct function -


what looking suggestion regarding formula use macro. macro meant search column string ( "can" ), , return summation of of corresponding numeric values column 3 rows over, long case sensitive string present.

i've searched vba version of vlookup, tried sumproduct, index/match, etc., necessity of macro being not case sensitive summation of multiple numeric values has led roadblocks of these functions.

i not experienced programmer means, , sorry if post vague. make simpler (hopefully), i'm looking best function use if want make macro take following list, search "apples", , have value 21 return.

if not site for... let me know , i'll delete post.

oranges apples  $10   apples oranges  $12   pears grapes    $14   grapes oranges  $18   apples oranges  $19   oranges pears   $16   apples oranges  $11  

i reiterate here: pivot tables. they're little intimidating @ first, designed track kind of data. link gives tutorial.

if adamant done in vba, should pretty easy, vba string compare case sensitive.

basically, want loop through each cell in columns (you can use loop rows.count this, or while loop did below). compare value of each cell "can". if it's equal, total = total + cell.offset(0,2).value.

edit

excel workbook

sub countapple()     dim total integer     dim integer     dim col integer     total = 0     = 1     col = 1 'this search a. 2 search b, , on     while not worksheets("sheet1").cells(i, col).value = ""             if cells(i, col).value = "apple"                 total = total + cells(i, col).offset(0, 2).value            end if            = + 1     wend     msgbox (total) 'displays 8 end sub 

this code work (provided there no empty rows in a). if there don't understand it, don't hesitate contact me :)


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -