Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I need help with my code, its only doing something simple but I've tried select case statements and if...then statements. I'm very much a newbie so.... (Xn) means Column X, Row n I want to add currency values in a column, (Gn) based on the criteria in three other columns, i.e. Add the value of (Gn) to a variable when (An) = 4 AND (Cn) = Test AND (Hn) = Parts. I've tried some simple code that defines the necessary variables, I've got a command button on the sheet where the data is and the code is in their too, all it seems to do at the moment is assign the initialisation value to the variable and then put this in the cell at the end, it just seems to ignore the logic in the IF loop, although if I get it to print out a msgbox for each of the variables it loops through the entire range Im looking at. I don't get any errors with the logic, it just doesn't perform the action I expect. The actual code (after the dim statements and variable initialisation is For i = 10 To 260 mnth = Cells(i, 1).Value prj = Cells(i, 3).Value cat = Cells(i, 8).Value subtot = Cells(i, 7).Value If (Cells(i, 1).Value = 4 And Cells(i, 3).Value = "Test" And Cells(i, 8).Value = "Consumables") Then AstCon3 = AstCon3 + subtot I've also tried it this way... If mnth = "4" And prj = "Test" And cat = "Consumables" Then AstCon3 = AstCon3 + subtot End If Next i Range("AB1002") = AstCon3 Can anyone give me some pointers please J |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need sum of top values in a range based on criteria | Excel Worksheet Functions | |||
Sum of values based on different criteria | Excel Discussion (Misc queries) | |||
Sum unique values based on criteria | Excel Worksheet Functions | |||
Looking up values based on two criteria | Excel Worksheet Functions | |||
adding values based on criteria | Excel Worksheet Functions |