Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get The Length of data type of excel using visual basic

Dear Reader,

I need length of the data type of excel and also want to know the
technique to set the Excel column data type. These things I want with
the help of Visual Basic Code.

If it is possible to do so then please reply me as soon as possible.

Regards,

Sanjay Bol

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Get The Length of data type of excel using visual basic

The length:

Function length(R As Range) As Integer
Dim s As String
s = R.Value
length = Len(s)
End Function


To set format:

Sub Macro1()
Columns("F:F").Select
Selection.NumberFormat = "@"
End Sub

Will, for example, set the format of the cells in column F to text.
--
Gary''s Student


" wrote:

Dear Reader,

I need length of the data type of excel and also want to know the
technique to set the Excel column data type. These things I want with
the help of Visual Basic Code.

If it is possible to do so then please reply me as soon as possible.

Regards,

Sanjay Bol


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Get The Length of data type of excel using visual basic

The Len function will return the number of bytes occupied by a
variable. E.g.,

Dim D As Double
Debug.Print Len(D)

With Strings, Len will return the number of characters stored in
the string variable. E.g.,

Dim S As String
S = "my string"
Debug.Print Len(S)

You can't set a column to a particular data type. All worksheet
cells are Variants; that is, they can store any type of
(non-object) values. You can use the NumberFormat property to
change the way Excel *displays* the data, but this is an "output"
function. It doesn't control what is actually stored in the cell,
nor does it control what can be input into a cell. It controls
only the displayed output.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



wrote in message
oups.com...
Dear Reader,

I need length of the data type of excel and also want to know
the
technique to set the Excel column data type. These things I
want with
the help of Visual Basic Code.

If it is possible to do so then please reply me as soon as
possible.

Regards,

Sanjay Bol



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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Passing a range of data to a function - Excel - visual basic dochoa Excel Programming 2 February 2nd 06 08:13 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
Visual Basic macro run time error(13) type mismatch Paul Excel Discussion (Misc queries) 0 October 25th 05 07:28 AM
visual basic & chart data labels LES Excel Programming 1 July 22nd 05 04:15 PM


All times are GMT +1. The time now is 02:59 AM.

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

About Us

"It's about Microsoft Excel"