Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Clearing an integer variable

I'm building a UserForm for data entry. I use a ComboBox to get a numeric
value and assign it to an integer (call it Prod). I put the value of Prod in
a cell of a worksheet.

If the user does not enter a value for Prod in the UserForm, I want the cell
on the worksheet to be blank. I tried Prod="" at the end of the sub, but that
gives a type mismatch error. I tried Prod=vbNull, but that puts a value of 1
in the cell. I tried Prod.ClearContents and that gave some other error
(don't remember which).

How do I make the value of an integer variable be empty?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Clearing an integer variable


Integer variables can only have integers values, not Null ir blanks. You
can set the variable to 0 and clear contents on the cell to which it
would otherwise be assigned. Or you could use a Variant and assign
vbNullString.


--
shg
------------------------------------------------------------------------
shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30494

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Clearing an integer variable

Thank you. I had forgotten about the "Variant" data type. Your suggestion
appears to do exactly what I wanted.
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
Macro - use variable integer as text Drahos Excel Programming 2 May 17th 06 09:51 AM
How do I convert an integer variable to a string variable? dumbass Excel Programming 2 May 21st 04 07:34 PM
How to specify a Range which includes an integer variable Hotbird[_3_] Excel Programming 4 May 7th 04 02:38 PM
Is variable an integer? Otto Moehrbach[_6_] Excel Programming 7 February 6th 04 04:31 PM
Use of integer variable for sizing of matrix Cor Steeghs Excel Programming 2 August 8th 03 12:56 PM


All times are GMT +1. The time now is 08:52 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"