Question Details

No question body available.

Tags

excel vba if-statement

Answers (2)

July 14, 2025 Score: 1 Rep: 56,852 Quality: Medium Completeness: 80%

A Worksheet BeforeDoubleClick: Run Procedures by Double-Clicking Cells

  • Compare the cells' addresses as mentioned by FunThomas in your comments.
  • Use the Select Case statement as suggested by Tim Williams in your comments.
  • Set Cancel to True when the cell is a desired one so you don't enter the edit mode of the formula bar.
    Leave it as is or set it to False when not.

Sub WorksheetBeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Cancel = True ' disable entering formula bar via double-click

Select Case Target.Address(0, 0) Case "F6" Main
Facture Case "F9" MainProforma Case "F12" MainBL Case Else Cancel = False ' enable entering formula bar via double-click End Select

End Sub

Sub MainBL() MsgBox "BL" End Sub Sub MainFacture() MsgBox "Facture" End Sub Sub Main_Proforma() MsgBox "Proforma" End Sub
July 14, 2025 Score: 1 Rep: 81,237 Quality: Low Completeness: 60%

Two different cells may have the same Value, but different address. The Range.Address property comes in handy.