Double Click Problem with Code

sarahrb1989

New Member
Joined
Dec 15, 2017
Messages
30
I am using an Excel file to store primarily demographic data. I have two pieces of code imbedded in this workbook that allows me to use a Combobox to select demographic data and change to an abbreviation.
For example Green -> GR, Purple ->PUR.

The code has affected my ability to double click in the workbook on cells that are not utilizing the code to use my cursor to type instead of using the formula bar. Please see the attached test file.

https://www.dropbox.com/s/nohdlxj35zdgrpa/Completed Test Log.xlsm?dl=0


Does anyone know how to modify this code to allow for double clicking inside cells not utilizing the code (no data validation lists) to give me my cursor back?? :eeek:

Any help is much appreciated.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Add this to the top of the doubleclick event
Code:
If Intersect(Target, Range("C:K")) Is Nothing Then Exit Sub
 
Upvote 0
I also just noticed a problem with typing in the M column. When ever I try to type text, it disappears. I checked the data validation does not have the "error message" checkbox selected. Could this be something to do with the second part of the code?

Any advice is greatly appreciated. :)
 
Upvote 0
On the file you supplied there is no data validation in col M.
I don't have any probs typing into that column
 
Upvote 0
Ok try this mod
Code:
           For Each Dn In Rng
                If LCase(Dn.Value) = LCase(Target.Value) Then
                    newVal = Dn.Offset(, -1).Value
 
Upvote 0
I replaced the piece of code you provided but it didn't work. The text still disappeared. I'm wondering if it is a setting of some sort. I'm really not sure.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim Rng As Range
Dim Dn As Range
On Error Resume Next
With Sheets("Demographics Options") 'Change Date sheet here as required
        Set Rng = .Range("R2", .Range("R" & Rows.Count).End(xlUp))
    End With
If Target.Count = 1 Then
  If Not Intersect(Target, Range("K:K")) Is Nothing Then
     Application.EnableEvents = False
            [COLOR=#FF8C00]For Each Dn In Rng
                If Dn.Value = Target.Value Then
                    newVal = Dn.Offset(, -1).Value[/COLOR]
                    Exit For
                End If
           Next Dn
            Application.Undo
            oldVal = Target.Value
            Target.Value = newVal
                If Not newVal = "" Then
                    Target.Value = IIf(oldVal = "", newVal, oldVal & ", " & newVal)
                End If
    Application.EnableEvents = True
    End If
End If
End Sub
 
Last edited:
Upvote 0
That code doesn't include my mod.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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