View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Add and summarize function

Hi Joe,

The following assumes that your table of data is in Data A1:A8 with the
first row as column headers (CODE VALUE)

Note that a space and underscore at the end of a line is a line break in an
otherwise single line of code.

Sheets("Output").Range("A2") = _
WorksheetFunction.SumIf(Sheets("Data") _
.Range("A2:A8"), "=XXX", Sheets("Data") _
.Range("B2:B8"))



--
Regards,

OssieMac


"joecrabtree" wrote:

All,

I have a worksheet called 'data' in which I have two colounms of data
shown below:

CODE VALUE
XXX 1
XXX 22
XXX 21
XXX 45
BBB 64
NNN 54
AAA 64

Using VBA how can I add up all the XXX codes and produce an output
total in a worksheet labelled 'output'?

For example in this case the worksheet 'output' would display

XXX 89


Thanks for your help,

Regards

Joe Crabtree