ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatted Number into String Variable, Excel VBA (https://www.excelbanter.com/excel-programming/356253-formatted-number-into-string-variable-excel-vba.html)

[email protected]

Formatted Number into String Variable, Excel VBA
 
Hello All,

I am using a script to take a list of phone numbers formatting them and
then doing a search with the phone number. I need to use the formatted
phone number to do the search.

Cell(2,3) before code is 12345678901
after code is +1 (234) 567 8901
Code Snippet:

Dim telephone as String
Columns("C:C").Select
Selection.NumberFormat = "+# (###) ### ####"
telephone = Cells(2,3).Value

End Code

The problem is that the variable "telephone" is equal to 12345678901
not the formatted +1 (234) 567 8901. Is there a way to convert the
formatted number into a string in VBA?

Excel 2003 VBA

Thanks in advanced
Matt


Doug Glancy

Formatted Number into String Variable, Excel VBA
 
Matt,

telephone = Format(Selection, "+# (###) ### ####")

hth,

Doug


wrote in message
oups.com...
Hello All,

I am using a script to take a list of phone numbers formatting them and
then doing a search with the phone number. I need to use the formatted
phone number to do the search.

Cell(2,3) before code is 12345678901
after code is +1 (234) 567 8901
Code Snippet:

Dim telephone as String
Columns("C:C").Select
Selection.NumberFormat = "+# (###) ### ####"
telephone = Cells(2,3).Value

End Code

The problem is that the variable "telephone" is equal to 12345678901
not the formatted +1 (234) 567 8901. Is there a way to convert the
formatted number into a string in VBA?

Excel 2003 VBA

Thanks in advanced
Matt




Tom Ogilvy

Formatted Number into String Variable, Excel VBA
 
or simpler

telephone = Cells(2,3).Text

No use repeating yourself. <g

--
Regards,
Tom Ogilvy

"Doug Glancy" wrote in message
...
Matt,

telephone = Format(Selection, "+# (###) ### ####")

hth,

Doug


wrote in message
oups.com...
Hello All,

I am using a script to take a list of phone numbers formatting them and
then doing a search with the phone number. I need to use the formatted
phone number to do the search.

Cell(2,3) before code is 12345678901
after code is +1 (234) 567 8901
Code Snippet:

Dim telephone as String
Columns("C:C").Select
Selection.NumberFormat = "+# (###) ### ####"
telephone = Cells(2,3).Value

End Code

The problem is that the variable "telephone" is equal to 12345678901
not the formatted +1 (234) 567 8901. Is there a way to convert the
formatted number into a string in VBA?

Excel 2003 VBA

Thanks in advanced
Matt






Doug Glancy

Formatted Number into String Variable, Excel VBA
 
Thanks Tom,

Your right, things are complicated enough as it is.

Doug


"Tom Ogilvy" wrote in message
...
or simpler

telephone = Cells(2,3).Text

No use repeating yourself. <g

--
Regards,
Tom Ogilvy

"Doug Glancy" wrote in message
...
Matt,

telephone = Format(Selection, "+# (###) ### ####")

hth,

Doug


wrote in message
oups.com...
Hello All,

I am using a script to take a list of phone numbers formatting them and
then doing a search with the phone number. I need to use the formatted
phone number to do the search.

Cell(2,3) before code is 12345678901
after code is +1 (234) 567 8901
Code Snippet:

Dim telephone as String
Columns("C:C").Select
Selection.NumberFormat = "+# (###) ### ####"
telephone = Cells(2,3).Value

End Code

The problem is that the variable "telephone" is equal to 12345678901
not the formatted +1 (234) 567 8901. Is there a way to convert the
formatted number into a string in VBA?

Excel 2003 VBA

Thanks in advanced
Matt









All times are GMT +1. The time now is 08:02 PM.

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