Filter if one or another value is equal to cell - vba

I need to solve one simple problem. I do have a one huge table that contains around 300000 rows with data and basically what I need is to filter out row if the cell in either G or L row is equal to cell in 'Input sheet'!C2.
Please see attached image.
So if the either G column or L column is containing value from cell then I want to copy entire row into sheet called 'Direct'. The 'Direct' will not contain empty rows.
As It is huge amount of data, that will grow a bit the code must be a bit optimized.
Many thanks in advance!!!
Cheers,
F.

Related

Master Spreadsheet, Referenced by presentation spreadsheet - potentially hard?

I just started a project for a client company and they're needing something kind of unrelated, I'm hoping to get some help with that here.
The situation is this. I have a continually updating "master" spreadsheet located at \ServerA\Folder1\Folder2\MasterSpreadsheet.xlsx. This houses dates ascending left to right on row 219. The dates are ascending(Format mm/dd/yyyy), but not sequential(they skip a few days here and there). The Quantity(row 220) corresponds with dates(row 219). These both start on Column C.
FIRST "Set" of dates/qty on row 219/220 Column C.
SECOND "Set" of dates/qty on row 224/225 Column C.
I then have a "Presentation" spreadsheet that will reference the master.
Dates are ascending top to bottom (range 4/25/18 - 12/31/18) in column F and ARE SEQUENTIAL, qty in column G, starting row 9.
So basically what i need is an excel statement that will do this, in whatever fashion is needed.
If the FIRST AND SECOND sets' dates in the date row in MASTER match(could be in column C, all the way to column CZ), the quantities for them both will be added and placed into the correct row (Dates match) in the PRESENTATION spreadsheet.
If the FIRST AND SECOND sets' dates in the date row in MASTER DO NOT match, then they just go to their respective dates on the PRESENTATION spreadsheet.
I hope that was clear enough! Sorry to ask, i can do the rest but this really has me stumped.
Thank you very much!!!!!
I do not understand why you differentiate match or not match for master sets date.
I suggest in sheet PRESENTATION from cell G9 :
=SUMIF(MASTER!$C$219:$CZ$219,PRESENTATION!F9,MASTER!$C$220:$CZ$220)+SUMIF(MASTER!$C$224:$CZ$224,PRESENTATION!F9,MASTER!$C$225:$CZ$225)

VBA excel Copy Paste

Hi, I am totally new to Excel VBA. Firstly, I want to copy the data when the condition is met(copy data with reference to 144)
Secondly, compare the cells, if it is IT Operations(Table1) to IT Operations(Table2) then copy the price(money) to column F. If the variable is no there then leave blank.
This can be done with formulas. Here is one way of thinking about filling column F, with the prices for the matching items in column E, by matching the number given in the last row in E (144 Total); which i shall assume is E10 in this case.
Total formula in F1 which you then drag down is:
=IFERROR(IFERROR(VLOOKUP(E1,INDIRECT(CELL("address",OFFSET($H$1,MATCH(1*LEFT($E$10,FIND(" ",TRIM($E$10),1)-1),$G:$G,0)-1,,1,1))&":"&CELL("address",OFFSET($I$1,MATCH($E$10,$G:$G,0)-1,,1,1))),2,FALSE),VLOOKUP(E1,G:I,3,FALSE)),"")
In steps:
Extract the number of interest e.g. 144, and get rid of any trailing/leading whitespace using:
LEFT($E$10,FIND(" ",TRIM($E$10),1)-1)
Find which row this value is in as this will be the first row of the lookup range for this number. *1 converts text to a number.
MATCH(1*LEFT($E$10,FIND(" ",TRIM($E$10),1)-1),$G:$G,0)
This gives row 9.
We can use something simpler to find the last row of the range, which holds 144 Total
MATCH($E$10,$G:$G,0)
This gives row 15. So we know the data lies between rows 9 and 15 for 144.
We can turn this into a range to use in a VLOOKUP with INDIRECT and OFFSET.
=CELL("address",OFFSET($G$1,MATCH(1*LEFT($E$10,FIND(" ",TRIM($E$10),1)-1),$G:$G,0)-1,,1,1))&":"&CELL("address",OFFSET($H$1,MATCH($E$10,$G:$G,0)-1,,1,1))
This gives us $G$9:$H$15. Note adjustments of -1, to put OFFSET back in the right row, and that the OFFSET start cells are in different columns to provide the columns required for the VLOOKUP.
So we can now lookup column E values e.g. Enhancement, in our newly defined range which is accessed via INDIRECT:
=VLOOKUP(E1,INDIRECT(CELL("address",OFFSET($H$1,MATCH(1*LEFT($E$10,FIND(" ",TRIM($E$10),1)-1),$G:$G,0)-1,,1,1))&":"&CELL("address",OFFSET($I$1,MATCH($E$10,$G:$G,0)-1,,1,1))),2,FALSE)
This is saying VLOOKUP(E1,$G$9:$H$15,2,FALSE) i.e. get the price column from the range for the item specified in E1.
If this is not found i.e. returns #N/A, we can use this to first check if this is because of the merged cell that holds the 144 Total; where the value is actually in column G not H, and use an IFERROR to say, if not found in $G$9:$H$15 then try for a match using columns G:I and return column 3.
Which with pseudo formula, using priorLookup as placeholder, for the formula described in the steps above, looks like:
IFERROR(priorLookup, VLOOKUP(E1,G:I,3,FALSE))
If this still returns #N/A, we know the value is not present and we should return "". This we can handle this with another IFERROR:
IFERROR(IFERROR(priorLookup, VLOOKUP(E1,G:I,3,FALSE)),"")
So giving us the entire formula stated at the start.
Here it is used in the sheet:

Excel - Loop through rows and reverse order

I was looking for a code that loop through all rows (I got too many), and change order for every three rows. I have a form of rows like this...
see image
Need to loop through all rows in column B and reverse order for every three rows and get this (for better analysis). Thank you
see image
If I understand your question correctly, type this formula into a cell in column B and drag down as far as necessary:
= INDEX(A:A,ROW()+2*(1-MOD(ROW()-1,3)))
VBA is not needed. This formula copies the values from column A to column B, but reverses the order of the entries every three rows as shown in your example image from your question.
See below.

Adding a row between cell with the same value using VBA code

Im new in VBA and want to know how can i format my table in such a way that each name in Column one do only have 1 row in between.
Some of them do have more than 1 row in between and some of them doesn't have. I just need to format then in such a way where every name on column A has 1 blank row in between. Any help would be appreciated!
Please note that i have thousands of data so manual will not work.
also i tried doing the filtering and convert them into single block. the problem with single block is that my column c do have more than 1 information which is connected to column a, .
here is an example.enter image description here

Concatenating alternate columns

I have 10,000 rows and unlimited data in columns. Two parameters in adjacent columns and are repeating after 13 unwanted columns.
I want to concatenate these adjacent columns of a row separated by space
eg:
concatenate(B2,C2,"",P2,Q2,"",AC,AD,"",....)
But I dont know upto which column the data is present.
Can you suggest me a macro which concatenates data upto blank column in one cell of a row and same is continued for first 10,000 rows.
Thanks a lot for help !
First off, are all the rows terminating at the same column? i.e. does every row have data in column AD but not AE?
If the answer to the above is 'yes', then you'll probably want to take a look at:
Range.End()
which is used like:
YourSheet.Range(YourRange).End(xlToRight).Column
(see here for more info)
This will return either
the last column with data (when the starting cell contains data)
or
the first column with data (when the starting cell is empty).
not the last column without data!
Based on your example in the question, your ranges probably start in Column B, P, AC, etc.
If the answer to the above is 'no', then you can use similar functionality, but you'll have to loop through each row...