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
Related
I am writing a formula to run a matching analysis on some elements of a spreadsheet. The column containing the formula already has values filled in, but I need to run the formula on the blank cells. The formula is working but overwriting the current info I have within the filled cells.
I have tried a VBA code which got too complicated and did not work. With VBA I tried inserting the formula into only the blank spaces but was having some issues. I have also tried a basic excel formula.
=IF(COUNTIFS(A:A,A2,BU:BU,"CLOUD")=0,"Not Cloud",IF(COUNTIFS(A:A,A2,BU:BU,"NOT CLOUD")=0,"Cloud","Hybrid"))
VBA Code I tried:
If (IsEmpty(Bucket) Or Bucket = "" Or Bucket = vbNullString) And _
(GetCellValue(.Cells(i, "BU")) = "CLOUD") Then
Range("CC:CC").Formula = "=IF(COUNTIFS(A:A,A2,BU:BU,""CLOUD"")=0,"Not Cloud", _
IF(COUNTIFS(A:A,A2,BU:BU,"NOT CLOUD")=0,"Cloud"","Hybrid"))"
A reminder this is a high-level version
I want that formula to only run in the cells that do not have a value already in place. It should not overwrite the data from the VBA script that I previously ran before doing the formula. The disposition column should be completely full of values. The formula needs to run in only the blank cells.
You could achieve this with an additional column.
In the column to the right of Disposition (insert one if necessary) write the following formula (example for row 2, assuming Disposition is Column C):
=IF(C2=""; [Your formula here]; C2)
This will provide you with a column full of values, anytime you put a value into column C it will override the formula.
Edit: You can then copy this formula down the entire column to achieve the desired effect.
I have a dashboard (image below) where I manually add entries. Then there is a log (image below) where all entries are recorded with the help of IF and Vlookup functions.
I need a code so so that every output cell in the log finds through all the entries in the dashboard and gives the answer. I think loop for vlookup will be used.
[Edit]
Consider the Dasboard table as a discrete table where manually entries are posted.
Consider log table as a continues table where record of every hour for each date is kept. The entries from Dashboard table get posted to the log table. New Image attached New Image
I have entered this function in output column in the log table:
=IF( AND(H3=$B$3,I3>= $C$3,I3<$D$3) ,$E$3,0) + IF(AND(H3=$B$4,I3>=
$C$4,I3<$D$4) ,$E$4,0) + IF (AND(H3=$B$5,I3>= $C$5,I3<$D$5), $E$5,0)
This works fine for me for plotting the entries but the problem is for every row in the dashboard i have to add a new IF-And function in the above. so for example if i want to add the 4th row of dashboard to be sync with the log ill have to add
+If(AND(H3=$B$6,I3>=$C$6,I3<$D$6),$E$6,0)
I want every row in the dashboard to add automatically somehow with a loop like:
i = variable
= If (AND(H3=$B$i,I3>= $C$i,I3<$D$i), $E$i,0)
Only one i will be greater than 0 while the rest will be zero. so the function should return me the sum of all i rather than just the last iteration.
Maybe just filldown the formula manually? if insist with macro, something like
Sub test()
Range("K3").Value = "X"
Range("K3:K10").FillDown
End Sub
replace "X" with your formula, keep the " "
replace K10 with how far down you want
----edit----
let me break down below for you,
match(H3,B:B,0), will find the correct row in B that = H, in H3 case it finds B3
INDEX(B:E,MATCH(H3,B:B,0),2) -> now it find B3, index let you find C3 (notice the 2,3,4 in later codes, it means the column from B3)
and (I3>=...,J3>=...)now we got both start and end time, we use I and J to compare
if 3. is true, lookup the output column, else 0
=IF(AND(I3>=INDEX(B:E,MATCH(H3,B:B,0),2),J3>=INDEX(B:E,MATCH(H3,B:B,0),3)),INDEX(B:E,MATCH(H3,B:B,0),4),0)
I have a table in Word, each row is a few lines of text (shift + enter).
When I copy the table to Excel every line of copy to my own line. You can copy (each line where it was used (shift + enter)) to one row in Excel?
My table in Word.
Copied table to Excel.
I want to Row1 Text - Row1 TextC was A1. I know I can merge, but I have a big table and looking for solutions, which will accelerate.
This isn't 'easy' presuming you're comfortable with excel you're going to need to either use the VBA environment or have a few additional columns.
One way would be to identify the 'top' and 'bottom' of each Row by; in column C (starting from C2, C1 is always "top") =if(left(c2,4)<>left(c2,1),"Top", if(left(c2,4)<>left(c3,4),"Bottom","middle"
Then in column D (and cell locking is important, also assumes it goes to row 100, you will need to change this)
if(or(C1={"bottom","middle"}),"",$A1 & " - " & index($A1:$A$100,match("bottom", $A1:$A$100,0)))
This will give you a list, with breaks in which you can either remove by copying and pasting column D to a new sheet as values, pressing F5 and removing blanks. The other way would be to remove duplicates from the pasted list, and then take out the blank wherever it appears.
There may be more efficient ways of doing this, but it's a pretty unique question!
Maudise
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"))
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