Prevent loosing format when merging columns.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings,
I have a column where there has to be a five digit number. Sometimes the number will lead of with Zeros. I use

VBA Code:
Sub Tail_Number()
Range("E:E").NumberFormat = "00000"
End Sub

This does get me what I need. However when I merge Columns "D" and "E" I loose the 5 digit minimum format that I already established. The following VBA works fine apart from dropping leading zeros. For example I could end up with something like B737\959 while I want to have B737\00959

VBA Code:
Sub Merge_Acft_Tail()

For i = 1 To Cells(Rows.Count, "D").End(xlUp).Row
    Cells(i, "D").Value = Cells(i, "D").Value & "\" & Cells(i, "E").Value
Next i
Columns(5).Delete
End Sub

Thank you so much and happy New Year

End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try. text:
PHP:
Cells(i, "D").Value = Cells(i, "D").Value & "\" & Cells(i, "E").text
 
Upvote 0
Solution

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

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