Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default require cell input before macro can run

I have a macro that runs from a textbox click. I would like to require a cell
(say b19)
have data entered in it before the macro can run. I am having issues with
folks running the macro before all of the data is entered.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default require cell input before macro can run

You can add a check near the top of your subroutine:

Option Explicit
Sub Testme01()
'declarations

'your check
if isempty(activesheet.range("b19").value) then
msgbox "Please enter your data"
exit sub
end if

'rest of code here

End Sub

TBoy 1701 wrote:

I have a macro that runs from a textbox click. I would like to require a cell
(say b19)
have data entered in it before the macro can run. I am having issues with
folks running the macro before all of the data is entered.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default require cell input before macro can run

I've solved this problem in one of my user files by making a named range of
all the cells that are "required" entry (and enforce some data validation
rules on them). then:

Sub RunMyCode()

Dim GoAhead as Boolean
Dim CL as range

GoAhead = True
For Each CL in Range("Required").Cells
If CL = "" Then GoAhead = False
Next CL

If GoAhead = False Then
MsgBox "Please enter all required data."
Exit Sub
End If

'then whatever code you want to run if the required data is present.


"TBoy 1701" wrote:

I have a macro that runs from a textbox click. I would like to require a cell
(say b19)
have data entered in it before the macro can run. I am having issues with
folks running the macro before all of the data is entered.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default require cell input before macro can run

You might want to look at using Data Validation in cell B19 to make sure it
has the correct data in it, then you could use an If ... then statement in
in your textbox event code to check the content of B19:

Set sh = ActiveSheet
If sh .Range("B19"') < "" Then
'You existing code here
End If

Without the data validation, a user could enter any data into the cell and
the textbox event code would still run.


"TBoy 1701" <TBoy wrote in message
...
I have a macro that runs from a textbox click. I would like to require a
cell
(say b19)
have data entered in it before the macro can run. I am having issues with
folks running the macro before all of the data is entered.



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
Require input in a cell before saving file Patrick Riley Excel Discussion (Misc queries) 21 March 26th 08 02:47 PM
Require mandatory info input in order for Exel to save changes. VHG Excel Worksheet Functions 3 May 31st 07 12:40 PM
Have cell require input before saving. couriced Excel Discussion (Misc queries) 1 October 20th 05 04:36 PM
created form, want to require input No Name Excel Programming 0 July 29th 04 04:54 PM


All times are GMT +1. The time now is 01:06 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"