PC Review


Reply
Thread Tools Rate Thread

Setting up an If-Then condition off of a command box

 
 
=?Utf-8?B?QnVjczg1MDI3?=
Guest
Posts: n/a
 
      17th Sep 2007
I am trying to set up a command box that will do two things conditionally if
clicked. First, I want to run a macro that will validate that text is
present in a range of cells (all cells must have text values, although the
text values may vary). If all of the cells in the range contain text, then
the command button will take the user to the next sheet. If all the cells in
the range do not have text, the command button will spawn a message box
informing the user that all questions must be answered in order to continue.
If anyone can help with this, I would appreciate it! I have been trying to
figure this out for nearly a week!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      19th Sep 2007
Here is an example in which the user must fill in all the cells from A1 thru
A10:

1. first create a button using the Forms menu
2. assign the following macro to the button:

Sub empty_check()
Set r = Range("A1:A10")
n = Application.WorksheetFunction.CountA(r)
If n < 10 Then
MsgBox ("A1 thru A10 must fill filled in")
Exit Sub
Else
Sheets("Sheet2").Activate
Range("A1").Select
End If
End Sub

Adapt it to suite your range of cells
--
Gary''s Student - gsnu200745


"Bucs85027" wrote:

> I am trying to set up a command box that will do two things conditionally if
> clicked. First, I want to run a macro that will validate that text is
> present in a range of cells (all cells must have text values, although the
> text values may vary). If all of the cells in the range contain text, then
> the command button will take the user to the next sheet. If all the cells in
> the range do not have text, the command button will spawn a message box
> informing the user that all questions must be answered in order to continue.
> If anyone can help with this, I would appreciate it! I have been trying to
> figure this out for nearly a week!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with syntax for WHERE condition or just Condition =?Utf-8?B?U3VlIENvbXBlbGxpbmc=?= Microsoft Access Macros 0 22nd Jun 2005 08:11 AM
I need 4 condition for condition formatting =?Utf-8?B?U2VlS1k=?= Microsoft Excel Programming 2 7th Jun 2005 09:49 AM
Condition 1 OR Condition 2 Martin Microsoft Access Queries 3 23rd Aug 2004 03:38 PM
Condition is true in one cell, give me same condition in another T. Harris Microsoft Excel Misc 1 28th May 2004 08:20 PM
Re: Why isn't "(..)" working as a condition in the condition column? Ken Snell Microsoft Access Macros 0 14th Aug 2003 02:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:01 AM.