Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statement

Status
Not open for further replies.
Mar 26, 2004
19
0
0
GB
Hello all, here's the problem:

I have a named cell "Input_Check_1" and I want to run a Macro from a click event to check that the named cell is equal or greater than 10.

If it is 9 or lees i want a messange box to pop up....

If it is 10 or greater I have the code already to pop in the IF statement.

Any ideas, I'm struggling to make the transition form VB6 to VBA :(

Thanks
Greenthumb
 
OK here is some code I came up with, but why am I getting a message box whatever "Input_Check_1" is....ggrrrr

Sub IS1_Next()
Rem Swithces pages after checking input
Application.ScreenUpdating = False

If Input_Check_1 < 10 Then
MsgBox ("Please check your selection!")
Else
Sheets("Input Sheet.1").Visible = False
Sheets("Input Sheet.2").Visible = True
Sheets("Input Sheet.2").Select
End If
 
Because it doesnt understand that Input_Check_1 is a range - You need to use Range("Input_Check_1")

You should also declare it.

Sub IS1_Next()
Rem Swithces pages after checking input
Application.ScreenUpdating = False

Dim Input_Check_1 As Range

If Range("Input_Check_1") < 10 Then
MsgBox ("Please check your selection!")
Else
Sheets("Input Sheet.1").Visible = False
Sheets("Input Sheet.2").Visible = True
Sheets("Input Sheet.2").Select
End If
End Sub

Regards
Ken..............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Hi Ken,

Why declare it? It's not being used as a variable.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
LOL - Apologies Tony, that's me coming straight in last night after 200 miles of driving this weekend and being totally dense - Should have just gone straight to bed (Talk about addicted) :-(

Guess I just get declaration happy sometimes :)

Regards
Ken................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Aaahhhh! Addiction. I understand [lol]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
LOL - I have to believe your wife gives you as much grief about this stuff as mine, else I'll just get depressed :)

Regards
Ken................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top