ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if cell is greater than "" then run macro (https://www.excelbanter.com/excel-programming/319469-if-cell-greater-than-then-run-macro.html)

Brad

if cell is greater than "" then run macro
 
I'm trying to create a macro that will open a Userform. The requirement
would be, is if the end user enters any data in Cell L12 then the form would
open up, if that cell is blank then nothing would happen. The Data Value
would be Numerical or Text. I know this is a worksheet_change but not quite
sure what the proper coding is. Any help is appreciated.

JE McGimpsey

if cell is greater than "" then run macro
 
You'll need to use an event macro. Put this in the worksheet code module
(assuming a userform class named MyForm):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim frmUser As MyForm
With Target
If .Address(False, False) = "L12" Then
If Not IsEmpty(.Value) Then
Set frmUser = New MyForm
frmUser.Show
End If
End If
End With
End Sub




In article ,
"Brad" wrote:

I'm trying to create a macro that will open a Userform. The requirement
would be, is if the end user enters any data in Cell L12 then the form would
open up, if that cell is blank then nothing would happen. The Data Value
would be Numerical or Text. I know this is a worksheet_change but not quite
sure what the proper coding is. Any help is appreciated.


Bob Phillips[_6_]

if cell is greater than "" then run macro
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$L$12" And Target.Value < "" Then
UserForm1.Show
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Brad" wrote in message
...
I'm trying to create a macro that will open a Userform. The requirement
would be, is if the end user enters any data in Cell L12 then the form

would
open up, if that cell is blank then nothing would happen. The Data Value
would be Numerical or Text. I know this is a worksheet_change but not

quite
sure what the proper coding is. Any help is appreciated.





All times are GMT +1. The time now is 04:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com