Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extracting data type from variable


Is is possible to extract the data type of a variable? For example let
say I have two variables X and Y

Dim X as Comment
Dim Y as Range

I now want to evalute what data type X is. Is their a property fo
type?

IF X.Type = Comment Then

et

--
ExcelMonke
-----------------------------------------------------------------------
ExcelMonkey's Profile: http://www.excelforum.com/member.php...nfo&userid=522
View this thread: http://www.excelforum.com/showthread.php?threadid=27680

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Extracting data type from variable

Check out either TypeOf or TypeName()

--
Regards

Juan Pablo González

"ExcelMonkey" wrote in message
...

Is is possible to extract the data type of a variable? For example lets
say I have two variables X and Y

Dim X as Comment
Dim Y as Range

I now want to evalute what data type X is. Is their a property for
type?

IF X.Type = Comment Then

etc


--
ExcelMonkey
------------------------------------------------------------------------
ExcelMonkey's Profile:

http://www.excelforum.com/member.php...fo&userid=5221
View this thread: http://www.excelforum.com/showthread...hreadid=276807



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Extracting data type from variable



If you Dim x as comment it would always return "Comment",
wouldn't it?

Sub TypeTest()
Dim x As Object
Dim y As Variant

Set x = ActiveCell
x.Value = 1
y = x.Value

'Typename returns a string with the Class or Type name
If TypeName(x) = "Range" Then Stop
If TypeName(y) = "Double" Then Stop

'TypeOf can be used on objects
'note you use the IS keyword.

If TypeOf x Is Range Then Stop

End Sub





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


ExcelMonkey wrote :


Is is possible to extract the data type of a variable? For example
lets say I have two variables X and Y

Dim X as Comment
Dim Y as Range

I now want to evalute what data type X is. Is their a property for
type?

IF X.Type = Comment Then

etc

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
extracting numbers from variable text JulianActon Excel Discussion (Misc queries) 8 November 7th 05 12:33 AM
Extracting variable sized strings from binary file luis Excel Programming 1 October 18th 04 07:45 PM
How to find out the data type of a variable in VBA ? Adrian[_7_] Excel Programming 1 September 5th 04 05:00 PM
What data type for Variable? Jeff Armstrong Excel Programming 4 August 6th 04 09:38 PM
efine the data type of a variable monika Excel Programming 0 February 13th 04 02:01 AM


All times are GMT +1. The time now is 07:39 PM.

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"