Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Vick
 
Posts: n/a
Default Using a Input Box Value in an if statement

I'm trying to create an If, then, else statment using the value of an input
box.

So lets say the variable of my input box is vdate and it returns 6 how would
I write the IF statement to true if vdate = 6. If VDATE = 6 then? What am I
missing?

Thanks for your help!
  #2   Report Post  
Posted to microsoft.public.excel.misc
Marcelo
 
Posts: n/a
Default Using a Input Box Value in an if statement

Hi Vick,

try if(vdate=6,"true","false")
you just replace the "true" and "false" for you need.

hope this help.
regards from Brazil
Marcelo

"Vick" escreveu:

I'm trying to create an If, then, else statment using the value of an input
box.

So lets say the variable of my input box is vdate and it returns 6 how would
I write the IF statement to true if vdate = 6. If VDATE = 6 then? What am I
missing?

Thanks for your help!

  #3   Report Post  
Posted to microsoft.public.excel.misc
Vick
 
Posts: n/a
Default Using a Input Box Value in an if statement

This looks like a formula, I'm looking for this in terms of a macro. Thanks
for the help though.

"Marcelo" wrote:

Hi Vick,

try if(vdate=6,"true","false")
you just replace the "true" and "false" for you need.

hope this help.
regards from Brazil
Marcelo

"Vick" escreveu:

I'm trying to create an If, then, else statment using the value of an input
box.

So lets say the variable of my input box is vdate and it returns 6 how would
I write the IF statement to true if vdate = 6. If VDATE = 6 then? What am I
missing?

Thanks for your help!

  #4   Report Post  
Posted to microsoft.public.excel.misc
Nick Hodge
 
Posts: n/a
Default Using a Input Box Value in an if statement

Vick

There are two types of inputbox (VBA's and Excel's). Excel's is prefixed
with Application and has slightly different parameters including what return
type in allows.

The VBA version returns a string, so if you are checking for an integer, you
should explicitly convert it using CInt(). The basic code below works

Sub ValueFromInputBox()
Dim vDate As String
vDate = InputBox("Enter a whole number", "Input")
If CInt(vDate) = 6 Then
MsgBox "True"
Else
MsgBox "False"
End If
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"Vick" wrote in message
...
I'm trying to create an If, then, else statment using the value of an
input
box.

So lets say the variable of my input box is vdate and it returns 6 how
would
I write the IF statement to true if vdate = 6. If VDATE = 6 then? What am
I
missing?

Thanks for your help!



  #5   Report Post  
Posted to microsoft.public.excel.misc
Marcelo
 
Posts: n/a
Default Using a Input Box Value in an if statement

sorry, i did not notice that you were looking for a Macro

regards

"Vick" escreveu:

This looks like a formula, I'm looking for this in terms of a macro. Thanks
for the help though.

"Marcelo" wrote:

Hi Vick,

try if(vdate=6,"true","false")
you just replace the "true" and "false" for you need.

hope this help.
regards from Brazil
Marcelo

"Vick" escreveu:

I'm trying to create an If, then, else statment using the value of an input
box.

So lets say the variable of my input box is vdate and it returns 6 how would
I write the IF statement to true if vdate = 6. If VDATE = 6 then? What am I
missing?

Thanks for your help!

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
If statement that does nothing when false higherlimits Excel Discussion (Misc queries) 1 May 26th 06 06:11 PM
If Statement based on blank fields alaxmen Excel Worksheet Functions 3 February 8th 06 08:00 PM
input box Monty Excel Discussion (Misc queries) 2 October 7th 05 08:33 AM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
Input Form vba help mdalzell Excel Discussion (Misc queries) 0 April 8th 05 03:57 PM


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