Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run Macro Only If 4 Cells Are Filled In By User In VBA


Hi again.

I have a sheet where the user is required to answer 4 question befor
continuing.
The user has to enter data into 4 cells before being allowed to pres
the continue button.

I have allready created the button to run the next operation whe
pressing "Continue", but I would like the button to be dis-enable
until all 4 cells are completed.

The cell refferences a

E6, E8, E10, and E12

The button is still currently named "CommandButton1_Click()" but thi
will be changed later.

I can use the code:

ActiveSheet.Shapes("CommandButton1").Visible = False

to hide the button if all cells are not completed, but I would prefe
to still see it but have it dis-enabled as if in the contro
properties. If I try to record a macro to disenable the button, th
only code that is recorded is the selection of the button.
Is there a way that this can be written in code? And where would
place the code, would it be in the Worksheet Selection_Change area?

Thanks For Any Help You Can Give.


Celtic_Avenger
:confused

--
Celtic_Avenge
-----------------------------------------------------------------------
Celtic_Avenger's Profile: http://www.excelforum.com/member.php...fo&userid=1410
View this thread: http://www.excelforum.com/showthread.php?threadid=26137

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Run Macro Only If 4 Cells Are Filled In By User In VBA

Hi Celtic_Avenger,

Try something like:

Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = Range("E6, E8,E10,E12")
If Application.CountA(rng) < 4 Then
MsgBox "All four questions need to be answered", _
vbInformation
Else
'\\ optionally hide the button
'Me.CommandButton1.Visible = False
'\\ or disable the button
'Me.CommandButton1.Enabled = False

'Your continue code
End If
End Sub


---
Regards,
Norman



"Celtic_Avenger" wrote in
message ...

Hi again.

I have a sheet where the user is required to answer 4 question before
continuing.
The user has to enter data into 4 cells before being allowed to press
the continue button.

I have allready created the button to run the next operation when
pressing "Continue", but I would like the button to be dis-enabled
until all 4 cells are completed.

The cell refferences a

E6, E8, E10, and E12

The button is still currently named "CommandButton1_Click()" but this
will be changed later.

I can use the code:

ActiveSheet.Shapes("CommandButton1").Visible = False

to hide the button if all cells are not completed, but I would prefer
to still see it but have it dis-enabled as if in the control
properties. If I try to record a macro to disenable the button, the
only code that is recorded is the selection of the button.
Is there a way that this can be written in code? And where would I
place the code, would it be in the Worksheet Selection_Change area?

Thanks For Any Help You Can Give.


Celtic_Avenger



--
Celtic_Avenger
------------------------------------------------------------------------
Celtic_Avenger's Profile:
http://www.excelforum.com/member.php...o&userid=14101
View this thread: http://www.excelforum.com/showthread...hreadid=261374



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
Stop user from saving workbook unless cell is filled in Churley Excel Discussion (Misc queries) 3 October 16th 08 04:44 PM
Filled cells dont appear as filled SMILLS Excel Discussion (Misc queries) 6 October 18th 07 05:28 PM
Macro Request: Fill in empty cells with previous Filled cell in column Artis Excel Worksheet Functions 2 June 25th 07 08:30 PM
Run Macro when cell is filled JackR Excel Discussion (Misc queries) 4 March 21st 06 11:26 PM
Macro that copy page to page just some filled cells LC Excel Discussion (Misc queries) 0 May 13th 05 11:22 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"