Help with Excel VBA

H

Howard

-- I have a spread sheet as follows:
In Column B1 thru B8, I have listed names of workers. In Column C1 thru C8
are cells to hold total hours work. In Column G1 thru G30 are the workers
names listed again, (not in any order, and usually more than once), and to
the right in Column H1 thru H30 are the hours worked on a single job.

I need a way to look at the name in B1, search through column G1:G30 until a
name match is found, look to the right in Column H and find the hours worked,
add them to a variable, then continue on down the list in column G for the
next match, and add those hours to the variable. When finished with G1:G30,
the total hours in the variable will be transferred to cell C1 next to the
name, and the variable reset to zero.

Then we would go down to the name in B2, and start over until finished with
all the names in column B1:B8

I know this is long, but if someone can at least help me get started I would
really appreciate the help. Select Case won't work for what I need.
 
C

Chip Pearson

You don't need VBA. You can use the SUMIF function. E.g.,

In C1, enter

=SUMIF($G$1:$G$30,B1,$H$1:$H$30)

and fill down to C8.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
H

Howard

I tried to reply yesterday, but it didn't work. Thanks for your help. This
worked great. I had to make a couple of adjustments to tweek it, but I
really did appreciate your help. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top