How do I input these formulas into cells that I want written in?

P

Paige

If an employee input a dollar amount into G12, can I mandate he fill in what
the purpose was in A12? If he doesn't fill in the annotation in A12, then he
has to remove the dollar amount in G12 before proceeding with the rest of the
form. The highest dollar amount used in G12 would be $75.

Want dollar amount in G12
Want text in A12

I can make it work outside my cells with
Cell I formula
=IF(AND(G12>0,A12=""),"Error"," ")

Cell J formula
=IF(AND(G12>0,A12=""),"Need to fill out column A","OK")

How do I make it work inside my cells?
 
G

Gary''s Student

Enter the following Event macro in the workshet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r1 = Range("G12")
Set r2 = Range("A12")
If Intersect(r1, t) Is Nothing Then Exit Sub
If r2.Value <> "" Then Exit Sub
Application.EnableEvents = False
t.Clear
r2.Select
Application.EnableEvents = True
MsgBox ("Enter a reason in A12")
End Sub



Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
B

Bernard Liengme

You cannot put a formula into either A12 or G12 since this is where you want
to enter data.
I would use conditional formatting. Select A12 and open the Conditional
Formatting dialog; use the formula =AND(G12>12, ISBLANK(A12) and set a
bright red fill colour.

For the $75 limit on G12 use Data Validation

If you need help with either topic, please return
 
P

Paige

I was able to get this line to work. It is what I wanted.

I have read the links you told me to read. I can't figure out how to make
several lines do the same thing.

I need this same code from
G12 and A12
to
G41 and A41
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top