Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with SUMIF in VBA

For one of my projects for work I have to add on to a VBA program that
someone else has written. I'm new to VBA and I've learned a lot over
the last few weeks but I need some help with this code. First of all,
what is the format for SUMIF and what does it do? Also, can someone
help me decipher this code? It's part of a much larger file but I'll
just post a piece of it here, hopefully someone can at least give me
an idea of what it is doing. I know that the code is pulling values
from somewhere, I'm just not sure where and how to modify it. Thank
you so much!

Dim colIndex, rwIndex, numofchems
Range("a5").Select
ActiveCell.FormulaR1C1 = "=counta(RC[1]:R[100]C[1])" 'Counts # of
different chemicals
numofchems = ActiveCell.Value
For colIndex = 3 To 7
For rwIndex = 5 To (numofchems + 4)
If colIndex = 3 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-1],'806UPWFinal2.XLS'!Organicyr)"
If colIndex = 4 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-2],'806UPWFinal2.XLS'!
Organiclbws)"
If colIndex = 5 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-3],'806UPWFinal2.XLS'!Organicgws)"
If colIndex = 6 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-4],'806UPWFinal2.XLS'!Organicppm)"
If colIndex = 7 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-5],'806UPWFinal2.XLS'!OrganicCOD)"
Next rwIndex
Next colIndex

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Help with SUMIF in VBA

You have the format for SUMIF in your code.

It simply checks a range for a particular value, and sums a second range
where there is a match. The two ranges can be the same. But this is all
explained in help.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
oups.com...
For one of my projects for work I have to add on to a VBA program that
someone else has written. I'm new to VBA and I've learned a lot over
the last few weeks but I need some help with this code. First of all,
what is the format for SUMIF and what does it do? Also, can someone
help me decipher this code? It's part of a much larger file but I'll
just post a piece of it here, hopefully someone can at least give me
an idea of what it is doing. I know that the code is pulling values
from somewhere, I'm just not sure where and how to modify it. Thank
you so much!

Dim colIndex, rwIndex, numofchems
Range("a5").Select
ActiveCell.FormulaR1C1 = "=counta(RC[1]:R[100]C[1])" 'Counts # of
different chemicals
numofchems = ActiveCell.Value
For colIndex = 3 To 7
For rwIndex = 5 To (numofchems + 4)
If colIndex = 3 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-1],'806UPWFinal2.XLS'!Organicyr)"
If colIndex = 4 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-2],'806UPWFinal2.XLS'!
Organiclbws)"
If colIndex = 5 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-3],'806UPWFinal2.XLS'!Organicgws)"
If colIndex = 6 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-4],'806UPWFinal2.XLS'!Organicppm)"
If colIndex = 7 Then Cells(rwIndex, colIndex) =
"=SUMIF('806UPWFinal2.XLS'!tool,RC[-5],'806UPWFinal2.XLS'!OrganicCOD)"
Next rwIndex
Next colIndex



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" Harry Seymour Excel Worksheet Functions 9 June 12th 07 10:47 PM
Embedding a Sumif in a sumif C.Pflugrath Excel Worksheet Functions 5 August 31st 05 07:31 PM
sumif help... Jambruins Excel Discussion (Misc queries) 3 June 27th 05 04:56 PM
nested sumif or sumif with two criteria dshigley Excel Worksheet Functions 5 April 5th 05 03:34 AM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM


All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"