Move all data from selected rows, into the top most selected row.

Travis Kunnen

New Member
Joined
Feb 24, 2016
Messages
21
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All

Another problem.

Im seeking a function or macro to move all the data from a selected series of rows, into the top most row of the selected area.
Example below. There are 12 rows of Romboutsia (84 to 95), and all rows will (/should) have 1 data point. Im looking to move all the data from the selected rows, into the top most row for this group. So the data from C87, needs to move into C84, D90 into D84, E93 into E84, etc etc...
There will never be two sets of data in the rows, for the same selected grouping of names from column A.
Then I can repeat the process for the next set, the Ruminococcus, and so on and so forth....

Macro Top 20.xlsm
ABCDEFGHIJKLM
84Romboutsia0,0872162
85Romboutsia0,02813
86Romboutsia0,03553
87Romboutsia0,077430923
88Romboutsia0,21361
89Romboutsia0,11849
90Romboutsia0,047901507
91Romboutsia0,032
92Romboutsia0,01558
93Romboutsia0,02124862
94Romboutsia0,02868
95Romboutsia0,0124
96Ruminococcus0,01897662
97Ruminococcus0,014345097
98Ruminococcus0,014001448
99Ruminococcus0,0106
Layer 1
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You can check the below formula approach as well :
Book2
ABCDEFGHIJKLM
84Romboutsia0.087216
85Romboutsia0.028128
86Romboutsia0.035531
87Romboutsia0.077431
88Romboutsia0.213611
89Romboutsia0.118493
90Romboutsia0.047902
91Romboutsia0.031996
92Romboutsia0.015576
93Romboutsia0.021249
94Romboutsia0.028684
95Romboutsia0.012396
96Ruminococcus0.018977
97Ruminococcus0.014345
98Ruminococcus0.014001
99Ruminococcus0.010598
100
101Romboutsia0.0872160.0774310.0479020.0212490.0281280.2136110.0319960.0286840.0355310.1184930.0155760.012396
102Ruminococcus0.0189770.0143450.014001   0.010598     
Sheet1
Cell Formulas
RangeFormula
A101:A102A101=UNIQUE(A84:A99)
B101:M102B101=XLOOKUP($A101,FILTER($A$84:$A$99,B$84:B$99<>""),FILTER(B$84:B$99,B$84:B$99<>""),"")
Dynamic array formulas.
 
Upvote 0
Thank you very much for trying it on a real life situation.
As you mentioned, rpaulson has it covered for you. I'll have a look at the approach I took in case there is only a single entry.
 
Upvote 0
If you insert this line
Code:
If .Find(dataArr(j), , , 1, , 1).Address <> .Find(dataArr(j), , , 1, , 2).Address Then
after this line
Code:
With ActiveSheet.Columns(1)
and insert
Code:
End If
like so
Code:
        .Offset(1).Resize(.Rows.Count - 1).Delete Shift:=xlUp
    End With
End If    '<----- Insert here
End With
it eliminates the single entry problem.
 
Upvote 0
Hello @jolivanes
Please see below image. The left image is the after macro used from rpaulson (after I removed rows manually), and the right one is yours.
Yours worked for the first few genus' but then coped wrong data starting at row 12.
So the Alkalibacterium data in cell B12 belongs to Alkaliflexus in B13. But the Alkalibacterium in cells E, F, G 12 are correct.
And the Alkaliflexus data in C13 belongs to Alkaliphilus in D16.
The current data in D13 (0.00087822) belongs to Alkalitalea 5 rows below.
I didnt go through the whole data set, but this is within the 1st screen.
 

Attachments

  • test.gif
    test.gif
    204.7 KB · Views: 11
Upvote 0
The downside of my suggestion is the use of SpecialCells, empty cells in this case.
If a cell looks to be empty but has an apostrophe or a non printable character in it, it does not work as intended.
You can, if you want to, check if cells are really empty but you have a perfect macro from rpaulson so I don't know if you want to go that route.
 
Upvote 0
I will check. But the data set I use is from an online data base, so all empty cell should be empty.
The macro from rpaulson works well, but I still do have to manually delete the cless from where data was copied from, into the upper row.
Still... manually deleting rows is a HUGE time saver compared to manually moving all of the data.
 
Upvote 0
Maybe I am missing something. If you spot it, let us know
 

Attachments

  • Before And After.jpg
    Before And After.jpg
    80.2 KB · Views: 8
Upvote 0
Are the values in Column A all in blocks of the same values or are they scattered?
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,629
Members
452,661
Latest member
Nonhle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top