Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
how to convert a number to text in vba, e.g. showing 5 as "005". I can do it
on spreadsheet with a function like '=Text(A1,"000")'. can it be done in vba? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
sStr = format(5,"000")
-- Regards, Tom Ogilvy "Scott" wrote: how to convert a number to text in vba, e.g. showing 5 as "005". I can do it on spreadsheet with a function like '=Text(A1,"000")'. can it be done in vba? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub routine()
Dim n As Integer, s As String n = 5 s = Format(n, "000") MsgBox (s) End Sub -- Gary''s Student gsnu200711 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here are my codes:
Dim i As Long, lastrow As Long lastrow = Range("A1").CurrentRegion.Rows.Count For i = 1 To lastrow Cells(i, 8) = Format(Cells(i, 6), "000") Next I still got numbers, not text. "Gary''s Student" wrote: Sub routine() Dim n As Integer, s As String n = 5 s = Format(n, "000") MsgBox (s) End Sub -- Gary''s Student gsnu200711 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim i As Long, lastrow As Long
lastrow = Range("A1").CurrentRegion.Rows.Count For i = 1 To lastrow Cells(i, 8) = "'" & Format(Cells(i, 6), "000") Next -- Regards, Tom Ogilvy "Scott" wrote: Here are my codes: Dim i As Long, lastrow As Long lastrow = Range("A1").CurrentRegion.Rows.Count For i = 1 To lastrow Cells(i, 8) = Format(Cells(i, 6), "000") Next I still got numbers, not text. "Gary''s Student" wrote: Sub routine() Dim n As Integer, s As String n = 5 s = Format(n, "000") MsgBox (s) End Sub -- Gary''s Student gsnu200711 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It works!
Thank you, Tom. "Tom Ogilvy" wrote: Dim i As Long, lastrow As Long lastrow = Range("A1").CurrentRegion.Rows.Count For i = 1 To lastrow Cells(i, 8) = "'" & Format(Cells(i, 6), "000") Next -- Regards, Tom Ogilvy "Scott" wrote: Here are my codes: Dim i As Long, lastrow As Long lastrow = Range("A1").CurrentRegion.Rows.Count For i = 1 To lastrow Cells(i, 8) = Format(Cells(i, 6), "000") Next I still got numbers, not text. "Gary''s Student" wrote: Sub routine() Dim n As Integer, s As String n = 5 s = Format(n, "000") MsgBox (s) End Sub -- Gary''s Student gsnu200711 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
format([a1],"000")
-- Kind regards, Niek Otten Microsoft MVP - Excel "Scott" wrote in message ... | how to convert a number to text in vba, e.g. showing 5 as "005". I can do it | on spreadsheet with a function like '=Text(A1,"000")'. can it be done in vba? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert text number to number formate | Excel Discussion (Misc queries) | |||
Convert a number formatted as text to a number in a macro | Excel Programming | |||
convert text-format number to number in excel 2000%3f | Excel Discussion (Misc queries) | |||
not able to convert text, or graphic number to regular number in e | Excel Worksheet Functions | |||
Convert number in text format to number | Excel Programming |