![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 19
|
i need to know how to make a macro which can check a number of cells to make sure that there is something written in them. this presence check is to make sure the user hasn't forgotten to type the data in the cells.
Thankz |
|
|
|
|
|
#2 |
|
New Member
Join Date: Apr 2002
Posts: 41
|
When do you want to check the input?
What I mean is: what will the user do to trigger the check? You could check all the cells when the user goes to another sheet, but only if you are sure they will. How it would be done depends on what the user is likely (or preferably will) do. Regards Robb__ |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 19
|
I WANT DO DO A PRESENCE CHECK WHEN A BUTTON WITH A MACRO IS PRESSED. HOW DO I DO THIS. THIS BUTTON WILL BE CALLED PRESENCE CHECK.
THANKZ |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
How about this macro :
Sub aaa() Range("asdf").Select ran1 = Range("asdf") mycount = WorksheetFunction.CountA(ran1) mycount = Selection.Count If rowcount <> mycount Then MsgBox ("error") End If End Sub You will need to name the range of cells you're checking ( I've used "asdf" ). |
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2002
Posts: 19
|
the formula u gave me dosent work. it always shows the error message when i press the button. was i supossed to put anything between the <>.
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
Sorry - I'd not checked the code properly.
Sub aaa() Range("ASDF").Select ran1 = Range("asdf") mycount = WorksheetFunction.CountA(ran1) rowcount = Selection.Count If rowcount <> mycount Then MsgBox ("error") End If End Sub |
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2002
Posts: 41
|
I think the variables may be duplicated. Try this slight amendment:
Sub aaa() Range("asdf").Select ran1 = Range("asdf") rowcount = WorksheetFunction.CountA(ran1) mycount = Selection.Count If rowcount <> mycount Then MsgBox ("error") End If End Sub I haven't tested it, but it could be the answer. Any help? Regards Robb__ |
|
|
|
|
|
#8 |
|
New Member
Join Date: Apr 2002
Posts: 19
|
thankz, now it works perfect.
but i need to tell the macro that if all the cells were filled in, then it should now copy and paste the cells to another place. but if it found a cell empty then it shoul only show the erroe message and stop. thankz |
|
|
|
|
|
#9 |
|
New Member
Join Date: Apr 2002
Posts: 19
|
can u please help me with the last problem.
and now i have another question. what if the cells that i want to check are not in a list. i.e i wand to check cells C3,C5,C7 and C9. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|