![]() |
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! |
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! |
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! |
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! |
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! |
All times are GMT +1. The time now is 08:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com