ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Require entry in one cell if data in another (https://www.excelbanter.com/excel-programming/444947-require-entry-one-cell-if-data-another.html)

[email protected]

Require entry in one cell if data in another
 
I am trying to make it so that if there is ANY data in cell b17, then
there MUST be data entered in I17 and L17. Can anyone pleae help me
with this? I want these to be "beforeprint" events...

GS[_2_]

Require entry in one cell if data in another
 
presented the following explanation :
I am trying to make it so that if there is ANY data in cell b17, then
there MUST be data entered in I17 and L17. Can anyone pleae help me
with this? I want these to be "beforeprint" events...


Try...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Sheets("WhatsItsname") 'substitute actual value
If Not .Range("B17") = "" Then
.Range("I17") = myValue1 'substitute actual value
.Range("L17") = myValue2 'substitute actual value
End If 'Not .Range("B17") = ""
End With
End Sub

--
Garry

Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



Cimjet[_3_]

Require entry in one cell if data in another
 
Hi
One more for you to try.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim a As Range, b As Range, c As Range
Set a = Sheets("sheet1").Range("B17") 'You need to change the name of the
sheet is it's not sheet1
Set b = Sheets("sheet1").Range("i17")
Set c = Sheets("sheet1").Range("L17")
If a "" Then
If b = "" Or c = "" Then
MsgBox "You need to fill in the two cells i17 & L17"
Cancel = True
End If
End If
End Sub
HTH
Cimjet

wrote in message
...
I am trying to make it so that if there is ANY data in cell b17, then
there MUST be data entered in I17 and L17. Can anyone pleae help me
with this? I want these to be "beforeprint" events...



Cimjet[_3_]

Require entry in one cell if data in another
 
Hi
Ignore the first one because of text overwrap
One more for you to try.
'You need to change the name of the
sheet if it's not "sheet1"

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim a As Range, b As Range, c As Range
Set a = Sheets("sheet1").Range("B17")
Set b = Sheets("sheet1").Range("i17")
Set c = Sheets("sheet1").Range("L17")
If a "" Then
If b = "" Or c = "" Then
MsgBox "You need to fill in the two cells i17 & L17"
Cancel = True
End If
End If
End Sub

HTH
Cimjet

wrote in message
...
I am trying to make it so that if there is ANY data in cell b17, then
there MUST be data entered in I17 and L17. Can anyone pleae help me
with this? I want these to be "beforeprint" events...




All times are GMT +1. The time now is 10:36 PM.

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