Modify code to use "X" as one click in a Clicked Cell

Corried

Board Regular
Joined
Dec 19, 2019
Messages
217
Office Version
  1. 2019
Platform
  1. Windows
  2. Web
Hello Everyone.

How can I modify code to work around all worksheet, in my workbook.

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim rInt As Range
Dim rCell As Range

Set rInt = Intersect(Target, Range("D6:H141"))
If Not rInt Is Nothing Then
For Each rCell In rInt
rCell.Value = "x"
Next
End If
Set rInt = Nothing
Set rCell = Nothing
Cancel = True
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Can you explain a little better? Are you trying to use this throughout the entire sheet>?? and only when there is an 'X' or 'x' in the cell?? or ??
 
Upvote 0
If your wanting this same script to work in all sheets on your active workbook.
And your wanting a x to be entered in the cell you double click on then use this script.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on any sheet tab
Select View Code from the pop-up context menu

Look in far left corner of window and double click on ThisWorkbook
Paste the code in the VBA edit window
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
'Modified  1/24/2020  10:28:24 PM  EST
If Not Intersect(Target, Range("D6:H141")) Is Nothing Then
Cancel = True
Target.Value = "x"
End If
End Sub
 
Upvote 0
If your wanting this same script to work in all sheets on your active workbook.
And your wanting a x to be entered in the cell you double click on then use this script.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on any sheet tab
Select View Code from the pop-up context menu

Look in far left corner of window and double click on ThisWorkbook
Paste the code in the VBA edit window
VBA Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
'Modified  1/24/2020  10:28:24 PM  EST
If Not Intersect(Target, Range("D6:H141")) Is Nothing Then
Cancel = True
Target.Value = "x"
End If
End Sub
Thanks everyone for your commits and your support. I really appreciated your swift reply.

"My Aswer Is This" Your code did work wonderfully. Thanks again.

Solution Solve
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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