Macro to move negative values to another column

bridgfordkid

New Member
Joined
Apr 15, 2017
Messages
2
Hi,

I have a long list of bank transaction which are all in the same column. I want to be able to move the negative values one space to the right so that debits and credits are in separate columns.

Could anyone assist with how to do this. It's been 20+ years since I wrote any basic code and I don't know where to start.

Thanks a lot.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi & welcome to the board.
How about
Code:
Sub SplitNeg()
   Dim Ary As Variant
   Dim i As Long
   Ary = Range("C2", Range("C" & Rows.Count).End(xlUp))
   ReDim Preserve Ary(1 To UBound(Ary), 1 To 2)
   For i = 1 To UBound(Ary)
      If Ary(i, 1) < 0 Then
         Ary(i, 2) = Ary(i, 1)
         Ary(i, 1) = ""
      End If
   Next i
   Range("C2").Resize(UBound(Ary), 2).Value = Ary
End Sub
This will work on data in col C
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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