ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Number Formatting when joining two strings (https://www.excelbanter.com/excel-programming/322168-number-formatting-when-joining-two-strings.html)

mike

Number Formatting when joining two strings
 
Thanks in advance for any help.

I have the following code.

Dim AA As Integer
Dim bb
Dim cc
Dim ee
AA = ActiveCell.Offset(0, 1)
bb = ActiveCell.Offset(0, -3)
cc = ActiveCell.Offset(1, -3)
ee = " "
ActiveCell = AA & ee & bb & ee & cc

AA is the employee ID. bb and cc are first and last names.
I am trying to join the three into one cell. If the
employee ID is 123 I want it to appear as 00123 in the
newly formed string.

Currently it appears as "123 Joe Smith"
I want it to be "00123 Joe Smith"

Does anyone know how to fix this? I am using Excel 2000.
Thanks again.

Ben

Number Formatting when joining two strings
 
AA = Format(ActiveCell.Offset(0, 1), "00###")

"Mike" wrote:

Thanks in advance for any help.

I have the following code.

Dim AA As Integer
Dim bb
Dim cc
Dim ee
AA = ActiveCell.Offset(0, 1)
bb = ActiveCell.Offset(0, -3)
cc = ActiveCell.Offset(1, -3)
ee = " "
ActiveCell = AA & ee & bb & ee & cc

AA is the employee ID. bb and cc are first and last names.
I am trying to join the three into one cell. If the
employee ID is 123 I want it to appear as 00123 in the
newly formed string.

Currently it appears as "123 Joe Smith"
I want it to be "00123 Joe Smith"

Does anyone know how to fix this? I am using Excel 2000.
Thanks again.


Tom Ogilvy

Number Formatting when joining two strings
 
Expanding on Ben's solution:

ActiveCell = format(AA,"00###") & ee & bb & ee & cc


--
Regards,
Tom Ogilvy


"Mike" wrote in message
...
Thanks in advance for any help.

I have the following code.

Dim AA As Integer
Dim bb
Dim cc
Dim ee
AA = ActiveCell.Offset(0, 1)
bb = ActiveCell.Offset(0, -3)
cc = ActiveCell.Offset(1, -3)
ee = " "
ActiveCell = AA & ee & bb & ee & cc

AA is the employee ID. bb and cc are first and last names.
I am trying to join the three into one cell. If the
employee ID is 123 I want it to appear as 00123 in the
newly formed string.

Currently it appears as "123 Joe Smith"
I want it to be "00123 Joe Smith"

Does anyone know how to fix this? I am using Excel 2000.
Thanks again.





All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com