Simple but complex code

ivbacol

New Member
Joined
Feb 24, 2012
Messages
3
Hello all,

I am getting more and more familiar with VBA. Since I took some courses on Java I felt quite comfortable with my level of knowledge, until I had to combine different functions.

Bottom line I am looking for:
Upon a decimal number is entered, to be validated to fall between a range; if out of this range for the cell to turn red.
Regardless if out or not of this range to lock the cell.

I have coded so that it saves and protects upon exiting, can I also lock all other cells previously populated, several users will be using this spreadsheet.

I have been able to get very helpful bits from this forum, still I have not been able to put it together. Any suggestion is greately appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This is what I have in my module1

Sub auto_open()
ThisWorkbook.Sheets("Sheet1").OnEntry = "Validation"
End Sub

Sub Validation()
Dim isect As Excel.Range
Set isect = Range("C12:C20")
If isect.Value = 0 Then

Else
If (Val(ActiveCell.Value) < "$D$5" _
Or Val(ActiveCell.Value) > "$F$5") Then
ActiveCell.Interior.ColorIndex = 3
End If
ActiveCell.Locked = True
End If
End Sub

Many thanks!
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top