Move Numbers in adjacent cells

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, Kindly advice me for a VBA code so that to move the duplicate numbers from credit side which is col. "J" to col "I". Note that the code should move the second number. I present below an extract of original data and expected result. Thank you all in advance

Original data
DebitCredit
IJ
2 75.25
3 75.25
4 1500.88
5 1500.88

<colgroup><col style="mso-width-source:userset;mso-width-alt:995;width:21pt" width="28"> <col style="mso-width-source:userset;mso-width-alt:2531;width:53pt" width="71"> <col style="mso-width-source:userset;mso-width-alt:2531;width:53pt" width="71"> </colgroup><tbody>
</tbody>



Expected result

DebitCredit
IJ
2 75.25
375.25
4 1500.88
51500.88

<colgroup><col style="mso-width-source:userset;mso-width-alt:995;width:21pt" width="28"> <col style="mso-width-source:userset;mso-width-alt:2531;width:53pt" width="71"> <col style="mso-width-source:userset;mso-width-alt:2531;width:53pt" width="71"> </colgroup><tbody>
</tbody>
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Will the Debits always be in the row directly below the credit?
 
Upvote 0
Yeap alan, therefore that the original data are always below credit side and i would like to move each second number in debit side col. "I". Apologies for my faulty presentation. The first row is headings (Debit and Credit) in col. "I" and "J" respectively. Thank you for your respond. Hv a great day!
 
Upvote 0
Give this macro a try...
Code:
Sub MoveDuplicateNumbers()
  Dim R As Long
  For R = 2 To Cells(Rows.Count, "J").End(xlUp).Row
    If Cells(R, "J").Value = Cells(R - 1, "J").Value Then Cells(R, "J").Cut Cells(R, "I")
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,514
Messages
6,114,078
Members
448,547
Latest member
arndtea

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