How to Combine Cells with Numbers Into A Custom Number Format?

255 Views Asked by At

So I've been searching for a couple of hours now and am currently stuck. I've been given 3 columns with number values in them. In this particular scenario, they are measurements (feet, inches, quarter inches). I have been asked to combine the columns into a very specific number format that looks like this: ft-in-qt/04. So for example: the feet column says 10, the inches column says 4, and the quarter inches column says 1. I want to return 10-04-01/04 in a new column.

I'm using a For loop in a VBA sub to do a bunch of other operations, so I've included this bit in the for loop's code. I've successfully returned a text cell in the right format, but the company I'm sending it to wants it in a custom number format. What should I add to my code to get it in that ft-in-qt/04 format?

Dim TransporterI As Integer
For TransporterI = 2 To rowCount + 1
     'Open Gauge Reading
     Sheet1.Cells(TransporterI, 11).Value = Sheet3.Cells(TransporterI, 37) & "-" & Sheet3.Cells(TransporterI, 38) & "-" & Sheet3.Cells(TransporterI, 39) & "/04"
Next TransporterI
1

There are 1 best solutions below

0
On

How about this:

Dim TransporterI As Integer
For TransporterI = 2 To rowCount + 1
 'Open Gauge Reading
 Sheet1.Cells(TransporterI, 11).Value = Format(Sheet3.Cells(TransporterI, 37),"00") & "-" & Format(Sheet3.Cells(TransporterI, 38),"00") & "-" & Format(Sheet3.Cells(TransporterI, 39),"00") & "/04"
Next TransporterI