From: TBoy 1701 TBoy on
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.
From: Dave Peterson on
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
From: B Lynn B on
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.
From: JLGWhiz on
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 1701(a)discussions.microsoft.com> wrote in message
news:A6129435-82F8-4723-A96E-6173C0185A1B(a)microsoft.com...
>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.