# Populating a Cell Based Off of Two Columns Values

#### MDean3313

##### New Member
Hello again everyone,

I have two columns that I want to compare data and fill in a single cell with the SUM of one of those columns.

The first column is K. The cells are populated from K2:K59. There are 7 different values randomly listed in this column: Custom, Small Industrial, Lighting, SEM, Custom O&M, Prescriptive and Green Rewind. The second column, AT, has numerical values, also populated from AT2:AT259. I want to use a code that looks at column K to see which cells list "Custom." I want it to sum up the numerical values from column AT that correlate to "Custom" and sum up their values into a single cell.

I tried using this code to start:

=VLOOKUP(K2:K259,AT2:AT259,2,FALSE)

However, I feel as though I may need to use an IF and SUM statement to tell it to only look at the cells labeled "Custom" but am not sure how to format it.

If this doesn't make sense feel free to ask any questions.

Thanks everyone!

### Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

#### jtakw

##### Well-known Member
Hi,

Sounds like you just need SUMIF.

Use this with the criteria hard coded:

=SUMIF(K2:K259,"Custom",AT2:AT259)

Use this with a cell reference for the criteria, you can change A1 to whatever you want to SUM:

=SUMIF(K2:K259,A1,AT2:AT259)

#### MDean3313

##### New Member
I didn't even think about using the SUMIF function.

Thank you so much, you made my life about 100 times easier.

#### jtakw

##### Well-known Member
You're welcome, welcome to the forum, and thanks for the feedback.

1,101,894
Messages
5,483,550
Members
407,397
Latest member
HerbA

### This Week's Hot Topics

• Finding issue in If elseif else with For each Loop
Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
• MsgBox Error
Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
• CELL FORMAT - IF CONDITION
My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
• Show numbers nearly the same
Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...