ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell Auto Code (https://www.excelbanter.com/excel-programming/421836-cell-auto-code.html)

Randy

Cell Auto Code
 
Hello. I have a little formula/code of sorts that I am trying to tweak. The
code basically places an "X'" in a cell no matter what the user types into
the cell. Work great by the way! Now I want to make it even more difficult!!!
lol...

What I am trying to do is get this code to basically place an "X" in cell
G25, an "L" in cell G26, a "M" in cell G27, etc...no matter what a user might
type into the cell.

This is what I have to work with. If anyone has any suggestions I would
greatly appreciate. I thank you in advance for you time!

Private Sub Worksheet_Change_0(ByVal Target As Excel.Range)
Const sINPUTS As String = "G25, G26, G27"
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range(sINPUTS), .Cells) Is Nothing Then
If Not IsEmpty(.Value) Then
On Error Resume Next
Application.EnableEvents = False
.Value = "2"
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End With
End Sub


--
Randy Street
Rancho Cucamonga, CA

Randy

Cell Auto Code
 
Never mind...I got it...thanks anyways!
--
Randy Street
Rancho Cucamonga, CA


"Randy" wrote:

Hello. I have a little formula/code of sorts that I am trying to tweak. The
code basically places an "X'" in a cell no matter what the user types into
the cell. Work great by the way! Now I want to make it even more difficult!!!
lol...

What I am trying to do is get this code to basically place an "X" in cell
G25, an "L" in cell G26, a "M" in cell G27, etc...no matter what a user might
type into the cell.

This is what I have to work with. If anyone has any suggestions I would
greatly appreciate. I thank you in advance for you time!

Private Sub Worksheet_Change_0(ByVal Target As Excel.Range)
Const sINPUTS As String = "G25, G26, G27"
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range(sINPUTS), .Cells) Is Nothing Then
If Not IsEmpty(.Value) Then
On Error Resume Next
Application.EnableEvents = False
.Value = "2"
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End With
End Sub


--
Randy Street
Rancho Cucamonga, CA



All times are GMT +1. The time now is 12:40 PM.

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