I’m trying to create a formula that would copy all the numbers from one row into another row.
All I know how to do is mirror cells, but I can’t use that because the first row has other data in it besides numbers. I guess I"m looking for a way to just pick out the numbers
from Row A and place each number into it’s own cell on Row B.
It works, but it leaves gaps in the row. So if a cell from Row 1 is not a number it would create a blank cell in Row 2. I’m trying to figure out how to create Row 2 without any blank cells.
I can think of a number ways of kludging a solution using filters or some kind of formula with a running counter but all of them are going to be fragile and easily broken. Using a scripting language to filter the data is the most robust way to approach this; unfortunately, only Virtual Basic for Applications (VBA) is embedded within Excel, and although it would be straightforward to do this in VBA, it requires activing macros which is annoying and sometimes breaks compatibility between versions of Excel. This is an operation you could do on a text or CSV file with just a few lines of Python or Perl, but if you don’t know these languages or can’t deal with exporting the data to a CSV file, VBA is the way to go.
Do they need to be in order? If not once you use the formula and copy and then paste special values to remove the formulas and leave just the numbers you can sort them by value. The blank cells will all be first or last and can be removed.
If you do need them in order add a column with index nubers in order then sort all columns by the numbers you want remove the rows that are blank, then sort all comuins by the index numbers and things will be back in the original order.
One example of that (which might be a help to you) is that the newest versions of Excel have a =SORT(x) function that should be able to sort values within a row. My version of Excel does not have that feature, so I don’t know how it works.
This is one instance where your best solution is going to be a short macro.
Just copy/paste this code block into a macro and execute it when needed.
Should work in all versions of Excel since 2000. Probably all versions, but I can’t test that.
Sub CleanData()
Sheets("Sheet1").Columns(1).Copy Destination:=Sheets("Sheet1").Columns(2)
Set Rng = Range("B:B").SpecialCells(xlCellTypeConstants, 2)
Rng.Rows.Delete Shift:=xlShiftUp
End Sub