Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Code Modification

Looking to modify a code I have that put an "X" into a particular cell no
matter what the user types. Code work great! However, I need to modify the
code so that If an "X" is types into cell "B7", cell "F7" returns a null
value (or deletes any value in the cell)....but wait, that's not all...I also
need it to do the reverse....If user types an "X" into "F7" it should delete
any value in cell "B7"....kind of tricky I know...here is the code I have so
far:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sINPUTS As String = "B8,B10,B12,B15,F8,F10,F12,F15"
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 = "X"
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End With
End Sub

If anyone knows how or can assist in any way I would be forever grateful!
Thanks in advance for any assistance!
--
Randy Street
Rancho Cucamonga, CA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Code Modification

I did not test this, so you probably should before you install it permanently.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sINPUTS As String = "B8,B10,B12,B15,F8,F10,F12,F15"
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 = "X"
If .Address = "$B$7" Then
Range("$F$7") = ""
ElseIf .Address = "$F$7" Then
Range("$B$7") = ""
End If
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End With
End Sub


"Randy" wrote:

Looking to modify a code I have that put an "X" into a particular cell no
matter what the user types. Code work great! However, I need to modify the
code so that If an "X" is types into cell "B7", cell "F7" returns a null
value (or deletes any value in the cell)....but wait, that's not all...I also
need it to do the reverse....If user types an "X" into "F7" it should delete
any value in cell "B7"....kind of tricky I know...here is the code I have so
far:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sINPUTS As String = "B8,B10,B12,B15,F8,F10,F12,F15"
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 = "X"
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End With
End Sub

If anyone knows how or can assist in any way I would be forever grateful!
Thanks in advance for any assistance!
--
Randy Street
Rancho Cucamonga, CA

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
modification to this code James Excel Discussion (Misc queries) 0 March 23rd 09 09:20 PM
Code modification please Tom Excel Programming 3 April 27th 07 02:22 PM
Code modification help please Tom Excel Programming 2 April 10th 07 06:44 PM
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) Thulasiram[_2_] Excel Programming 4 September 26th 06 04:15 AM
modification for the code srinivasan Excel Programming 2 August 20th 05 03:12 PM


All times are GMT +1. The time now is 11:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"