![]() |
Warn if data is in range
I need a warning to appear when a user enter a value into A1, if there is a
value in any cell in the range B1:T1 Any one got a solution? Thanks Pat |
Hi Pat,
One way Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False With Target If .Address = "$A$1" Then If Application.CountA(Range("B1:T1")) 0 Then MsgBox "Data in B1:T1" End If End If End With 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) "Pat" wrote in message ... I need a warning to appear when a user enter a value into A1, if there is a value in any cell in the range B1:T1 Any one got a solution? Thanks Pat |
Try this:
Goto cell A1. Select menu: Data Validation... Tab: Settings Allow: Custom Formula: =COUNT(B1:T1)=0 Tab: Error Alert Title: Error Values present in B1:T1 Done! Ola Sandstrom |
Hi Pat
you can code a worksheet_change even to check to see if there is anything in B1:T1 when data is entered in A1 - e.g. ---- Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" And Target.Value < "" Then If Application.WorksheetFunction.CountIf(Sheets("Shee t3").Range("B1:T1"), "*") = 1 Then MsgBox "Range B1:T1 is not empty" End If End If End Sub --- to use the code, right mouse click on the sheet that you want to run the code against and choose view code copy & paste the above directly into the right hand side screen - if you get any red lines, click at the end of the line and press the delete key - this should fix up any line break problems. change "Sheet3" to the name of your sheet use alt & f11 to switch back to your worksheet and test Hope this helps Cheers JulieD "Pat" wrote in message ... I need a warning to appear when a user enter a value into A1, if there is a value in any cell in the range B1:T1 Any one got a solution? Thanks Pat |
All times are GMT +1. The time now is 02:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com