Improve VBA

Kazdima

Board Regular
Joined
Oct 15, 2010
Messages
226
Hello,

would you please improve the macro? The issue arises when I have numbers in both columns (A and B) in Debit and Credit.
For example In Debit 1,000 and in Credit 1,200. So, in column A should be (200) after running a Macro.

Sub MoveCredits_v3()
With Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
.Value = Evaluate(Replace(Replace("if(#="""","""",if(#=0,-^,#))", "#", .Address), "^", .Offset(, 1).Address))
.Offset(, 1).Clear '<- Optional to clear Credit column
End With
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
At the moment that formula is effectively this
=IF(A2="","",IF(A2=0,-B2,A2))
What should it be?
 
Upvote 0
Please take a minute to read the forum rules (again) on cross-posting, and then add the required link(s) to your post(s) in other forums. Thanks.
 
Upvote 0
HI Rory A,

I hope my posting is now correct?

This is a link to the thread ,which Peter helped me earlier :[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]https://www.mrexcel.com/forum/excel-questions/1067549-formula-macros-put-numbers-one-column-into-one-2.html#post5127652
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
No, I mean your posts on other forums. (which should be clear if you read the rules, as I asked. ;))
 
Upvote 0
Thanks for the link, now would you mind answering my question?
 
Upvote 0
I did not understand your question. I explained in my initial posting what I am looking for. Your formula does not combine two columns into one. Like I wrote, if you have in column A (debit) and in Column B (Credit), you formula puts number into column A and doesn ot pick up number from column B.
e.g. COlumn A=1000. Column B=(1200). So, after VBA use or formula, in COlumn A should be (200), not (1,200).
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
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