I'm working with an Excel file with more than a hundred columns containing thousands of values. However, I only need the first 504 values in each column and the remaining values in that same column need to be removed. The problem is that the values in the columns start in different rows.
Is there a solution to this problem?
I would suggest creating a filter for the entire worksheet and filter out null values giving you a selection of good data or delete the null values using the filter to select the null values. From there, delete the lines below your desired range.
I think you need to write a macro for that.
Your macro will scan your current sheet and will copy selected cells to
a new target sheet.
The macro has to include 2 loops:
outer loop will run on columns
inner loop will run on cells on curnet column
for each column
The inner loop will advance from cell 1 upwards untill it finds first cell
that its not null, when it finds it you have to write code that will copy
the next 504 cells on that same column to the target sheet
then the control will go to the outer loop that will increment to the next
column
you can assign Constant for MAX_COLUMNS that when the code reaches it
the macro will end.
Related
Using Excel, assumed there is a range of data including text and number values. But some are blank rows. How could I create a range of list which only includes non-blank rows using Excel functions? Thus, I don't have to copy, paste and remove blank rows by daily.
For example, Raw data table as below,
AAA 111 111 111 111
BBB 111 111 111 111
AAA 111 111 111 111
CCC 111 111 111 111
QQQ 111 111 111 111
SSS 111 111 111 111
BBB 111 111 111 111
Then, create a new range of table like this,
AAA 111 111 111 111
BBB 111 111 111 111
AAA 111 111 111 111
CCC 111 111 111 111
QQQ 111 111 111 111
SSS 111 111 111 111
BBB 111 111 111 111
I was trying to use this formula. However, it doesn't work...
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F1:J1))),"")}
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F2:J2))),"")}
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F3:J3))),"")}
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F4:J4))),"")}
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F5:J5))),"")}
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F6:J6))),"")}
{=IFERROR(INDEX($A$1:$E$12,SMALL(IF($A$1:$E$12<>"",ROW($A$1:$E$12)),ROW(F7:J7))),"")}
IF($A$1:$E$12<>"",ROW($A$1:$E$12)) in array context will result in a row vector {1,1,1,1,1} in case of row 1. So it always results in 5 times either the row number or FALSE for each row. So you will get each not empty row number 5 times.
One option would be only checking if column A is empty and having the array formula for each single cell instead of the single rows:
{=INDEX($A$1:$E$20,SMALL(IF($A$1:$A$20<>"",ROW($A$1:$A$20)),ROW(1:1)),COLUMN(A:A))}
Example:
Of course this is really not performant for big ranges. But I don't see another possibility using formulas.
What I would do is having a helper column using the array formula:
{=AND(A1:E1<>"")}
for each row.
And then sorting the table by this helper column descending.
A problem that I am trying to do is extract rows out of a spreadsheet. The spreadsheet has over 1200 entries. I have split them up into relevant worksheets so the information can be used. Each of the individual codes will be a worksheet
A sample of the data looks like
The formula that I have found is and trying to run from a separate work sheet is
INDEX(Master!$A$2:$D$13, SMALL(IF((INDEX(Master!$A$2:$D$13,,4,1)="wap"),
MATCH(ROW(Master!$A$2:$D$13),ROW(Master!$A$2:$D$13)), “”), ROWS(A2:$A$2)), ,1)
It fails on
MATCH(ROW(Master!$A$2:$D$13),ROW(Master!$A$2:$D$13))
Getting the dreaded #N/A
I need some help in solving the problem and a brief explanation of the solution would be helpful.
Unfortunately, it has to be done by formula, as I don't have access rights for a VBA query.
Here you go:
=IFERROR(
INDEX(Master!$A$2:$D$13,
SMALL(
IF(
INDEX(Master!$A$2:$D$13,,4)="wap",
INDEX(Master!$A$2:$D$13,,1),
COUNTA(Master!$A$2:$A$13)+1
),
ROWS(A2:$A$2)
),
COLUMN()
)
,"")
This must be entered as an array function. Instead of clicking out of the cell or pressing enter to exit the formula, press Ctrl+Shift+Enter.
The IF function iterates through every cell in column 4 of the Master array. If the Code is a match, the ID is passed. Otherwise, the number of master rows plus one is passed. This is important because it will produce an error in the final INDEX function, which will be escaped to "" (a blank string).
The SMALL function outputs the current row, or key in the generated array. The final INDEX function gets the intersect of the current column and the chosen row. Just copy this across however many columns you have on each sheet and down the number of rows that should be returned. Any additional rows (or columns) will pass the blank string. To be safe, I'd copy down the 1200 rows, but this could slow your processing (if it does, just set the calc mode to manual).
I cannot find answer to my need. All searches lead to more complex scenarios or just how to filter.
I have filtered a workbook to only display Rows with values in Column C between .01 and 5.55 successfully.
I then used a formula in a blank column ( J ) to add 1.35 to each of those values successfully. (=Cxx+1.35)
I need to now move those attained values in Column J to the replace the values in C and have those values retained when the filter is cleared.
In Continuing to search - Thru google I found:
https://support.office.com/en-us/art...8-272422419b59
But the method only moves a portion of the cells.
I highlight the modified values in Column J - they appear copied in blocks since there missing row numbers between them.
I highlight the Original values in C - (which is the same size data range) and tied Paste - Paste Values and Paste Special / Values but it does not paste correctly.
The First Cell is the only one that pastes correctly. Only about half the cells are replaced and those values are incorrect.
Am I using the correct method to accomplish my need ? Or am I going about it wrong ? It seems the "logical" way with other things I do in my spreadsheet but ... have not tried to edit filtered info before.
Thanks for looking
Why bother with the filtering?
Use this formula in column J, starting in row 2, copy down and then copy the whole column and use Paste Special > Values to paste into column C
=if(and(C2>=0.01,c2<=5.55),C2+1.35,c2)
Or, if you insist on doing the filtering method:
filter the data
enter your formula in the visible cells
clear the filter
select column J and copy
select column C and use paste special with the options "Values" and "Skip Blanks" ticked.
I have a table with a List of data in it. I have chosen
ws.Cells(ws.Rows.count,"A").End(xlUp).row
to find the first cell that is empty within column A.
The problem is that the code outcome is stuck on the length of the table despite having empty cells before the end table length. Clearing all cell formats and content within the table has not worked.
Does this particular code recognize the table element as cell occupancy? Or am I missing a portion of code? Thanks a bunch
ws.Cells(ws.Rows.count,"A").End(xlUp).row will find the last non-empty cell in column A.
To find the first empty cell in column A (assuming cell A1 itself is not empty) you could use:
ws.Cells(1,"A").End(xlDown).row + 1
I have a table that is pulling thousands of rows of data from a very large sheet. Some of the columns in the table are getting their data from every 5th row on that large sheet. In order to speed up the process of creating the cell references, I used an OFFSET formula to grab a cell from every 5th row:
=OFFSET('Large Sheet'!B$2572,(ROW(1:1)-1)*5,,)
=OFFSET('Large Sheet'!B$2572,(ROW(2:2)-1)*5,,)
=OFFSET('Large Sheet'!B$2572,(ROW(3:3)-1)*5,,)
=OFFSET('Large Sheet'!B$2572,(ROW(4:4)-1)*5,,)
=OFFSET('Large Sheet'!B$2572,(ROW(5:5)-1)*5,,)
etc...
OFFSET can eat up resources during calculation of large tables though, and I'm looking for a way to speed up/simplify my formula. Is there any easy way to convert the OFFSET formula into just a simple cell reference like:
='Large Sheet'!B2572
='Large Sheet'!B2577
='Large Sheet'!B2582
='Large Sheet'!B2587
='Large Sheet'!B2592
etc...
I can't just paste values either. This needs to be an active reference, because the large sheet will change.
Thanks for your help.
And here is one last approach to this that does not use VBA or formulas. It's just a quick and dirty use of AutoFilter and deleting rows.
Main idea
Add a reference to a cell =Sheet1!A1 and copy it down to match as many rows as there are in the main data.
Add another formula in B1 to be =MOD(ROW(), 5)
Filter column B and uncheck the 0s (or any single number)
Delete all the rows that are visible
Delete column B
Voila, formulas for every 5th row
Some reference images, these are all taken on Sheet2.
Formulas with AutoFilter ready.
Filtered and ready to delete
Delete all those rows (select A1, CTRL+SHIFT+DOWN ARROW, SHIFT+SPACE, CTRL+MINUS)
Delete column B to get final result with "pure" formulas every 5th row.
If you want to take a VBA approach to this, you can generate the references very quickly using simple For loops.
Here is some very crude code which can get you started. It uses hard-coded sheet names and variables. I am really just trying to show the i*5 part.
Sub CreateReferences()
For i = 0 To 12
For j = 0 To 5
Sheet2.Range("H1").Offset(i, j).Formula = _
"=Sheet1!" & Sheet1.Range("A5").Offset(i * 5, j).Address
Next
Next
End Sub
It works by building a quick formula using the Address from a reference to a cell on Sheet1. The only key here is have one index count cells in the "summary" rows and multiply by 5 to get the reference to the "master" sheet. I am starting at A5 just to match the results from INDEX.
Results show the formula input for H1 and over. I am comparing to the INDEX results generated above.
Here is one approach using INDEX instead of OFFSET. I am not sure if it is faster, I guess you can check. INDEX is not volatile, so you might get some advantage from that.
Picture of ranges, you can see that Sheet1 has a lot of data and Sheet2 is pulling every 5th row from that sheet. The data in Sheet1 goes from A1:F1000 and just reports the address of the current cell.
Formulas use INDEX and are copied down and across from A1 on Sheet2.
=INDEX(Sheet1!$A$1:$F$1000,ROW()*5,COLUMN())