Prevent loosing format when merging columns.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
703
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

bebo021999

Well-known Member
Joined
Jul 14, 2011
Messages
2,125
Office Version
  1. 2016
Try. text:
PHP:
Cells(i, "D").Value = Cells(i, "D").Value & "\" & Cells(i, "E").text
 
Upvote 0
Solution

Forum statistics

Threads
1,191,200
Messages
5,985,236
Members
439,953
Latest member
suchitha

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
Top