Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default format type in vbe

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default format type in vbe

Use the FORMAT function.. Try the below code within a mcro or from the
immediate window..


Range("A1") = Format(12,"000")


If this post helps click Yes
---------------
Jacob Skaria


"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default format type in vbe

The following iserts the number as a number rather than converting it to text.

Range("A1") = 27
Range("A1").NumberFormat = "000"

--
Regards,

OssieMac


"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default format type in vbe

Have you tested that Jacob? I can never get it to work unless the cell is
formatted to text.

--
Regards,

OssieMac


"Jacob Skaria" wrote:

Use the FORMAT function.. Try the below code within a mcro or from the
immediate window..


Range("A1") = Format(12,"000")


If this post helps click Yes
---------------
Jacob Skaria


"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default format type in vbe

This is a VB Script function...Try the below in immediate window...

Msgbox Format(2,"000")

If this post helps click Yes
---------------
Jacob Skaria


"OssieMac" wrote:

Have you tested that Jacob? I can never get it to work unless the cell is
formatted to text.

--
Regards,

OssieMac


"Jacob Skaria" wrote:

Use the FORMAT function.. Try the below code within a mcro or from the
immediate window..


Range("A1") = Format(12,"000")


If this post helps click Yes
---------------
Jacob Skaria


"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default format type in vbe

Apologies.. you are right
--
If this post helps click Yes
---------------
Jacob Skaria


"OssieMac" wrote:

Have you tested that Jacob? I can never get it to work unless the cell is
formatted to text.

--
Regards,

OssieMac


"Jacob Skaria" wrote:

Use the FORMAT function.. Try the below code within a mcro or from the
immediate window..


Range("A1") = Format(12,"000")


If this post helps click Yes
---------------
Jacob Skaria


"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default format type in vbe

You may want to reverse the order of these commands.

with range("A1")
.numberformat = "000"
.value = 27
end with

If the original/existing format of the cell were Text (@), then this order will
avoid a problem.

OssieMac wrote:

The following iserts the number as a number rather than converting it to text.

Range("A1") = 27
Range("A1").NumberFormat = "000"

--
Regards,

OssieMac

"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default format type in vbe

Thanks Dave. You are so right.
--
Regards,

OssieMac


"Dave Peterson" wrote:

You may want to reverse the order of these commands.

with range("A1")
.numberformat = "000"
.value = 27
end with

If the original/existing format of the cell were Text (@), then this order will
avoid a problem.

OssieMac wrote:

The following iserts the number as a number rather than converting it to text.

Range("A1") = 27
Range("A1").NumberFormat = "000"

--
Regards,

OssieMac

"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default format type in vbe

tx all i will try.. tomorrow now in italy i have to go to sleep !!
exactly i need it for composing the Fname with witch i will save the
workbook..

so it could be something like this..
myvalue = Range("a7").numberformat = 000

if i dont use this it will save 27 instead than 027..
its a little thing but it will make more to read clear a long list of files

tx..!


"OssieMac" wrote:

Thanks Dave. You are so right.
--
Regards,

OssieMac


"Dave Peterson" wrote:

You may want to reverse the order of these commands.

with range("A1")
.numberformat = "000"
.value = 27
end with

If the original/existing format of the cell were Text (@), then this order will
avoid a problem.

OssieMac wrote:

The following iserts the number as a number rather than converting it to text.

Range("A1") = 27
Range("A1").NumberFormat = "000"

--
Regards,

OssieMac

"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default format type in vbe

If you want to use it for a filename then you might want to set the number
format to text. Using Dave's code method but setting to text in lieu of a
numeric, it would be like this.

With Range("A1")
.NumberFormat = "@"
.Value = Format(27, "000")
End With

--
Regards,

OssieMac




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default format type in vbe

Sub test()
With Range("A1")
.NumberFormat = "000"
.Value = 12
End With
End Sub

HTH. Best wishes Harald

"OssieMac" wrote in message
...
Have you tested that Jacob? I can never get it to work unless the cell is
formatted to text.

--
Regards,

OssieMac


"Jacob Skaria" wrote:

Use the FORMAT function.. Try the below code within a mcro or from the
immediate window..


Range("A1") = Format(12,"000")


If this post helps click Yes
---------------
Jacob Skaria


"pls123" wrote:

hi all users !!
how can i specify the format type in vbe
for writing in a cell a number ??
i need a 000 style format
so 27 is a 027
ty for help !!
paolo


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to type format time in decimal format & calculate Cheyenne Excel Discussion (Misc queries) 1 February 12th 09 11:54 PM
Format Cell As You Type cooper Excel Programming 4 April 6th 06 01:53 AM
Adding new 'Type' to Format->Number->Time->Type Chip Pearson Excel Discussion (Misc queries) 5 September 26th 05 08:45 PM
Can I set the numerical type of Cell to Hex format hon123456 Excel Discussion (Misc queries) 2 January 13th 05 01:01 PM
UDF, Category, Data Type, Format, Using John Pierce Excel Programming 4 February 15th 04 04:17 PM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"