Writing BeforeDoubleClick VBA Code

Rob1972

New Member
Joined
May 19, 2018
Messages
9
Hi there, hoping someone can assist, this is my first post so apologies if i haven't quite got to grips with the posting process yet

I have a Private Sub routine currently set up in one of my excel spreadsheets which works well the code is as follows:

Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("$B$2:$B$100")) Is Nothing Then Exit Sub
Select Case Target
Case ""
Target = "FULLFILLED"
Target.Interior.ColorIndex = 4
Case Else
Target = ""
Target.Interior.ColorIndex = 3
End Select
Cancel = True
End Sub


What I want to be able to do is when I double click on a cell in range C2:C100 I want to be able to insert in the target field "Payment Taken" and on double click on a cell within the range D2:D100 i want to be able to insert "Dispatched" the interior colorIndex for these will be the same as those mentioned above.

I want to be able to do this in a way that each cell range is independent of each other.

I'm currently using the up to date version of Excel in MS Office 365

thank you for any assistance
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try this:
Code:
Private Sub Worksheet_BeforeDoubleclick(ByVal Target As Range, Cancel As Boolean)
'Modified 5/19/18 3:40 AM EDT
If Not Intersect(Target, Range("$B$2:$B$100")) Is Nothing Then
Cancel = True
If Target.Value = "" Then
Target.Value = "FULLFILLED"
Else
Target.Interior.ColorIndex = 3
End If
End If
If Not Intersect(Target, Range("$C$2:$C$100")) Is Nothing Then
Cancel = True
If Target.Value = "" Then
Target.Value = "Payment Taken"
Else
Target.Interior.ColorIndex = 3
End If
End If
If Not Intersect(Target, Range("$D$2:$D$100")) Is Nothing Then
Cancel = True
If Target.Value = "" Then
Target.Value = "Dispatched"
Else
Target.Interior.ColorIndex = 3
End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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