i have two sheets raw Data and Summary. i need help in editing below formula which i am using in my VBA code. i am looking for sum of one particular id for multiple conditions. in summary unique ids and i already have this formula which is working fine
=SUMPRODUCT(('Raw Data'!$A$2:$A$3457=A2)*('Raw Data'!$D$2:$D$3457={"HAUD","AANZ","CSHK","HCNY","CHN1,CHN2","IN1","DBIN","CSJL","CTOK","BTK","K01","MYFM","MYPB","HNZD","BNZD","PKDB","HSBP","SCS","SCTW","SCT","SCT"})*('Raw Data'!$F$2:$F$3457="BLF")*('Raw Data'!$G$2:$G$3457))
sum in "G" column sholud also include cells in D column which begins with "TW" or "K"
i tried this but its not working
=SUMPRODUCT(('Raw Data'!$A$2:$A$3457=A2)*(LEFT('Raw Data'!$D$2:$D$3457,2)="TW"))*(LEFT('Raw Data'!$D$2:$D$3457,2)="K"))*('Raw Data'!$D$2:$D$3457={"HAUD","AANZ","CSHK","HCNY","CHN1, CHN2","IN1","DBIN","CSJL","CTOK","BTK","K01","MYFM","MYPB","HNZD","BNZD","PKDB","HSBP","SCS","SCTW","SCT","SCT"})*('Raw Data'!$F$2:$F$3457="BLF")*('Raw Data'!$G$2:$G$3457)
your assistance highly appreciated
below one is also tried it shows blank all "," are replaced with * still shows Blank
=SUMPRODUCT('Raw Data'!$G$2:$G$3457,--('Raw Data'!$A$2:$A$3457=A2),(LEFT('Raw Data'!$D$2:$D$3457,2)="TW")+(LEFT('Raw Data'!$D$2:$D$3457,1)="K"),--ISNUMBER(MATCH('Raw Data'!$D$2:$D$3457,{"HAUD","AANZ","CSHK","HCNY","CHN1","CHN2","IN1","DBIN","CSJL","CTOK","BTK","K01","MYFM","MYPB","HNZD","BNZD","PKDB","HSBP","SCS","SCTW","SCT","SCT"},0)),--('Raw Data'!$F$2:$F$3457="BLF"))
I believe that the first formula should be more like:
=SUMPRODUCT(('Raw Data'!$A$2:$A$3457=A2)*('Raw Data'!$D$2:$D$3457={"HAUD","AANZ","CSHK","HCNY","CHN1","CHN2","IN1","DBIN","CSJL","CTOK","BTK","K01","MYFM","MYPB","HNZD","BNZD","PKDB","HSBP","SCS","SCTW","SCT","SCT"})*('Raw Data'!$F$2:$F$3457="BLF")*('Raw Data'!$G$2:$G$3457)*((LEFT('Raw Data'!$D$2:$D$3457,2)="TW")+(LEFT('Raw Data'!$D$2:$D$3457,1)="K")))
There was no quotes in "CHN1,CHN2" in both the first and the working formula that I added. I also changed
(LEFT('Raw Data'!$D$2:$D$3457,2)="TW"))*(LEFT('Raw Data'!$D$2:$D$3457,2)="K"))
to
((LEFT('Raw Data'!$D$2:$D$3457,2)="TW")+(LEFT('Raw Data'!$D$2:$D$3457,1)="K"))
The last one should work if you change the , in the array to ; (to mean a vertical array):
=SUMPRODUCT('Raw Data'!$G$2:$G$3457,--('Raw Data'!$A$2:$A$3457=A2),(LEFT('Raw Data'!$D$2:$D$3457,2)="TW")+(LEFT('Raw Data'!$D$2:$D$3457,1)="K"),--ISNUMBER(MATCH('Raw Data'!$D$2:$D$3457,{"HAUD";"AANZ";"CSHK";"HCNY";"CHN1";"CHN2";"IN1";"DBIN";"CSJL";"CTOK";"BTK";"K01";"MYFM";"MYPB";"HNZD";"BNZD";"PKDB";"HSBP";"SCS";"SCTW";"SCT";"SCT"},0)),--('Raw Data'!$F$2:$F$3457="BLF"))
Related
I am trying to create a pricing spreadsheet for the company I work for.
I am looking for a formula that returns a value from a specific cell based on text in two other cells.
An example is:
Sheet1:A1="Clear", Sheet1:B1="Black"
Sheet2:A1="Opacity", A2="Clear", A3="Yellow"
Sheet2:B1="Color", B2="Brown", B3="Black"
Sheet2:C1="Price", C2:1, C3:4
Return
IF Sheet1:A1="Clear" AND Sheet1:B1="Black", RETURN specific value from Sheet2:C column
Any tips or references I can look at to get this figured out?
I think below will help you to reach to the desired answer.
Add a new A column in sheet 2 (Later you can hide this)
sheet2:A1 -> =CONCATENATE(B2,",",C2) Drag to the End of the table.
sheet1:D1 -> =CONCATENATE(A1,",",B1) (Later you can hide this)
sheet1:C1 -> =VLOOKUP(D1,Sheet2!$A:$D,4,0) (What you expected)
Have you tried simple vlookup with the values ? Something like:
Vlookup ((sheet1$colA & sheet1colB), sheet2$colC, 1,0)
Try this. Will test for more and update.
I have a large data file that has some broken rows from the extraction process. I'm trying to clean it up in excel and am running into an issue with multiple row checking. I could nest a set amount of IF statements in my formula but that runs the risk of missing values. A Sample of the data looks like this (The strings are pasted into Column A):
'ID_Value','last_name','first_name','','dob','gender'comment
comment
comment
comment'
'ID_Value','last_name','first_name','','dob','gender'comment'
'ID_Value','last_name','first_name','','dob','gender'comment'
'ID_Value','last_name','first_name','','dob','gender'comment
comment
comment
comment
comment'
I need to roll the comment rows into the normal row preceding them. Currently I can identify all the rows and can make it work when there are two comment rows but going beyond that I am at a loss.
Formula in Column B: =IF(LEFT(A1, 1) = "'", "IGNORE", "FLAG")
Formula in Column C: =(IF(B2 = "FLAG", IF(B1 = "FLAG", "MOVE")))
Formula in Column D: =IF(B2 = "FLAG", IF(B1 = "FLAG", IF(C2 = "MOVE", CONCATENATE(A1, A2))))
Any recommendations are greatly appreciated.
Here you go this should do it.
Download the spreadsheet here.
Spreadsheet Example
Paste your data into Sheet 1 Cell A1 and click the run_filter button.
Alternatively you can first run it with the dummy data that already present in Sheet1 and check to see that the results work as expected.
A couple of caveats.
The macro will stop When it encounter a blank cell in Column A. This is how I determine that the macro should end.
Comments should contain no more than 5 commas otherwise they'll be interpreted as real data.
A space character is added to comments.
The first row should not contain a comment.
A new worksheet called Filtered_Result will be created with the required result.
If you want to view the code click on the developer tab.
If it's not present See here for How to add it tab
Then Click the Macro Button.
Click the edit button on the macro combine_comments to see the code.
Give it a try and let me know how it goes.
Peter H
I am trying to do relative referencing for a specific column (in Sheet "OA") where I need to retrieve the content of cells in a new sheet in steps of 110
e.g,
=OA!$AB217
=OA!$AB327
=OA!$AB437
Rather than manually code the formula in each cell, trying to drag the cells so the address could be dynamically generated.
On the above example, when I drag the cell, I am unable to get
=OA!$AB547
but getting
=OA!$AB220
I also tried to code it this way, "=OA!$AB($107+(n*$110))" where when the n values naturally incremented during the drag, I will get the right formula.
E.g
=OA!$AB($107+(1*$110)) => =OA!$AB217
=OA!$AB($107+(2*$110)) => =OA!$AB327
=OA!$AB($107+(3*$110)) => =OA!$AB437
=OA!$AB($107+(4*$110)) => =OA!$AB547
Unfortunately the format is not accepted by excel.
Could you please give me a hint what mistake I could have made ? My search on the internet have not been fruitful.
rgds
Saravanan K
You're looking for the "Indirect" function. Assemble a text string with the address of the cell you want, and call =indirect("string"). You can use the "&" operator to combine static strings with variables.
I've created a workbook with Sheet1 and OA
OA!A1:A1000 contain the numbers.
Sheet1!C1 contains 1
Sheet1!C2 contains 100
Sheet1!B1 contains =INDIRECT("OA!$A"&C1)
Sheet1!B2 contains =INDIRECT("OA!$A"&C2)
I am totally new to this kind of challenges and not sure any thing available ( not sure even on what base I have to search )
In the below excel sheet image the column 'A' has headings in two places ( row numbers 2,3 and 9,10) . The actual excel sheet has more than six thousand rows and too many sub headings like this ( If it is small file I can do it manually.. but more than 6 thousand rows)
The challenge :- I want to populate E column with "Make" value and F column with " Model" from sub headings . Can I write any rule or macro to populate these columns ? could some one help me ? Thanks for your help
Image Link
or below
Regards
Kiran
If you want to do this solely in Excel you can use the following. This assumes
All Headings are the same for "S.No"
Change the SUBSTITUTE clause to match the text for Make and Model eg I have used exact spacing of "Model: " and "Make : " to match the spreadsheet and substitute with ""
In cell G5 Enter =IF(ISNUMBER(A5),IF(ISERROR(FIND("Model",A3,1)),MAX($G$1:G4),MAX($G$1:G4)+1),"")
In cell F5 Enter =SUBSTITUTE(IF(ISNUMBER(A5),INDIRECT(ADDRESS(MATCH($G5,$G:$G,0)-2,COLUMN(A1),1)),""),"Model: ","")
In cell E5 Enter = =SUBSTITUTE(IF(ISNUMBER(A5),INDIRECT(ADDRESS(MATCH($G5,$G:$G,0)-3,COLUMN(A1),1)),""),"Make : ","")
Then drag down the formula in E5:G5 to wherever you need. However, I only recommend using this once only as the formulae will be slow to update over large ranges. Also if your headings are out of sync then VBA is the way forward
Col A,Col B,Col C
Test1,Test1,Test3
Test2,Test1,Test3
Is there a way to go thru all cells and pick out the unique values and place them in a new column or something?
Most of the answers on Getting unique values in Excel by using formulas only only work for values in a single column.
For a solution that works for values in multiple rows and columns, I found the following formula very useful, from http://www.get-digital-help.com/2009/03/16/unique-values-from-multiple-columns-using-array-formulas/
Oscar at get-digital.help.com even goes through it step-by-step and with a visualized example.
1) Give the range of values the label tbl_text
2) Apply the following array formula with CTRL + SHIFT + ENTER, to cell B13 in this case. Change $B$12:B12 to refer to the cell above the cell you enter this formula into.
=INDEX(tbl_text, MIN(IF(COUNTIF($B$12:B12, tbl_text)=0, ROW(tbl_text)-MIN(ROW(tbl_text))+1)), MATCH(0, COUNTIF($B$12:B12, INDEX(tbl_text, MIN(IF(COUNTIF($B$12:B12, tbl_text)=0, ROW(tbl_text)-MIN(ROW(tbl_text))+1)), , 1)), 0), 1)
3) Copy/drag down until you get N/A's.
If you are using Excel 2007 at least, then you can just use Remove Duplicates function from Data tab.
Otherwise I think a little bit of VBA fairy dust sprinkling is in order. I can mash up a quick VBA script if you need it.