Trouble Merging Cells

colbertja

New Member
Joined
Feb 20, 2013
Messages
3
I need some assistance in combining multiple cells into one and keeping the formatting the same. I currently have code that will combine the columns but it losses the leading zero on numbers less than 10. For instance I gave some examples of the current output.

CURRENT
HourMinSecResult
0953239'53'23
10420610'42'6
16004516'0'45

<tbody>
</tbody>

DESIRED
HourMinSecResult
09532309'53'23
10420610'42'06
16004516'00'45

<tbody>
</tbody>


Below is a copy of the current code that I am using that will combine the columns it just will not continue the leading zero. I am pretty sure the issue is when I do the actual combining I am using "cell.Value" and it is not keeping the values. I want to either find a way to treat the range of cells as a string or keep the number formatting when I combine the three cells.


Function CombineColumn(myRange As Range)


Dim cell As Range
For Each cell In myRange
If Len(cell) > 0 Then
CombineColumn = CombineColumn & cell.Value & "'"
End If
Next cell

If Len(CombineColumn) > 0 Then
CombineColumn = Left(CombineColumn, Len(CombineColumn) - 1)
Else
CombineColumn = ""
End If

End Function


-Thanks in advance
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
Office Version
  1. 365
Platform
  1. Windows
Change Cell.Value to Cell.Text.
 

colbertja

New Member
Joined
Feb 20, 2013
Messages
3
Norie, that worked perfect! I thought it was something that simple but couldn't find it anywhere.

Thanks!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,216
Messages
5,594,885
Members
413,947
Latest member
gizmolucy

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