How to not allow a formula to be entered into a cell

E

eluehmann

How can I do this? I want to lock a worksheet (except for a couple o
columns) and teh unlocked columns I do not want to allow people t
input formulas. Only numbers.... anyone?
 
D

Don Guillett

One way you might like
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 5 Then Exit Sub
If Target.HasFormula = True Then Target = ""
End Sub
 
J

Jason Morin

Right click on the worksheet tab, select View Code, and
past this into the window:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If .HasFormula Then
MsgBox "Sorry, you're not allowed " & _
"to enter formulas."
.Clear
.Select
End If
End With
End Sub
 
E

eluehmann

Just getting better and better... plub VB is tsrating to come back to
me! I am ashamed to say this but this may be the most excited I have
been all week!
 
D

Don Guillett

glad to help

--
Don Guillett
SalesAid Software
(e-mail address removed)
Don Guillett said:
One way you might like
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 5 Then Exit Sub
If Target.HasFormula = True Then Target = ""
End Sub
 
E

eluehmann

I thought about data validation at first... but it could really be an
number... it is in dollars so it could have cents and it could not..
there is really no minimum or maximum either... I put the abov
solutions together and have 100% what you would need if you needed t
do this. Thanks to everyone... truly a learning experienc
 

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