Automate Excel to shift data so the values in two rows match?
Solved/Closed
excellenthelp
Posts
4
Registration date
Friday 27 June 2014
Status
Member
Last seen
22 July 2014
-
27 Jun 2014 à 12:18
excellenthelp Posts 4 Registration date Friday 27 June 2014 Status Member Last seen 22 July 2014 - 22 Jul 2014 à 11:13
excellenthelp Posts 4 Registration date Friday 27 June 2014 Status Member Last seen 22 July 2014 - 22 Jul 2014 à 11:13
Related:
- How to shift data up in excel
- How to copy data from one excel sheet to another - Guide
- Audio pitch and shift - Download - Audio editing
- How to copy data to multiple worksheets in Excel - Guide
- Export data from excel - Guide
- How to change date format in excel - Guide
3 responses
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
3 Jul 2014 à 11:33
3 Jul 2014 à 11:33
Hi Emily,
The code below will temporarily place the result in columns E and F. So make sure they are empty or else change the column references in the code.
Get back to us if further assistance is desired.
Best regards,
Trowa
The code below will temporarily place the result in columns E and F. So make sure they are empty or else change the column references in the code.
Get back to us if further assistance is desired.
Sub RunMe()
Dim lRow, x As Long
lRow = Range("C1").End(xlDown).Row
For Each cell In Range("C2:C" & lRow)
x = 2
Do
If cell.Value = Cells(x, "B").Value Then
Range(Cells(cell.Row, "C"), Cells(cell.Row, "D")).Copy
Cells(x, "E").PasteSpecial
End If
x = x + 1
Loop Until Cells(x, "C") = vbNullString
Next cell
Range("E2:F" & lRow).Copy
Range("C2").PasteSpecial
Range("E2:F" & lRow).ClearContents
Application.CutCopyMode = False
End Sub
Best regards,
Trowa
excellenthelp
Posts
4
Registration date
Friday 27 June 2014
Status
Member
Last seen
22 July 2014
11 Jul 2014 à 11:17
11 Jul 2014 à 11:17
Hey Trowa!
Sorry it took a while for me to get back to you...I had to take your code and sort of "scale it up" to my actual spreadsheet. But it works great!! Thanks so much :)
I really appreciate the time and energy you put into this. You have saved us all a lot of headaches!
Thanks again,
Emily
Sorry it took a while for me to get back to you...I had to take your code and sort of "scale it up" to my actual spreadsheet. But it works great!! Thanks so much :)
I really appreciate the time and energy you put into this. You have saved us all a lot of headaches!
Thanks again,
Emily
excellenthelp
Posts
4
Registration date
Friday 27 June 2014
Status
Member
Last seen
22 July 2014
16 Jul 2014 à 11:39
16 Jul 2014 à 11:39
Hi Trowa!
The code you sent me works wonders on the sample spreadsheet I used for my example.
Unfortunately, when I run the code on my actual spreadsheet (which is obviously much longer, but same format), the code stops running when it hits a unique value in the C column that it can't match up with anything in the B column. Do you know any simple way to delete the cells in C and D when it can't find its "partner"??
Thanks again for all your help!
~Emily
The code you sent me works wonders on the sample spreadsheet I used for my example.
Unfortunately, when I run the code on my actual spreadsheet (which is obviously much longer, but same format), the code stops running when it hits a unique value in the C column that it can't match up with anything in the B column. Do you know any simple way to delete the cells in C and D when it can't find its "partner"??
Thanks again for all your help!
~Emily
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
17 Jul 2014 à 10:56
17 Jul 2014 à 10:56
Hi Emily,
But your example already had unique values in column C (2, 4 and 11) and they didn't show up at the result, right?
So what is the difference between your sample and actual data other then being a longer list?
If you don't mind you can upload your file (careful with personal info) using a file sharing site like www.speedyshare.com or ge.tt and then post back the download link.
Best regards,
Trowa
But your example already had unique values in column C (2, 4 and 11) and they didn't show up at the result, right?
So what is the difference between your sample and actual data other then being a longer list?
If you don't mind you can upload your file (careful with personal info) using a file sharing site like www.speedyshare.com or ge.tt and then post back the download link.
Best regards,
Trowa
excellenthelp
Posts
4
Registration date
Friday 27 June 2014
Status
Member
Last seen
22 July 2014
22 Jul 2014 à 11:13
22 Jul 2014 à 11:13
Hello Trowa-
I was able to figure it out this morning. Apparantely the spreadsheet I was using it on had some funny formatting, but now I got it! Thanks again for all your help!
~Emily
I was able to figure it out this morning. Apparantely the spreadsheet I was using it on had some funny formatting, but now I got it! Thanks again for all your help!
~Emily