![]() |
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. |
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 |
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. |
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. |
All times are GMT +1. The time now is 10:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com