I have written a program that uses Excel VBA to allow clients to sign in and out at the day care where I take my wife. I initially set up the program to ask the client to type in his client number, but now I want to have the client DoubleClick on his name in a list to get his sheet number. I cannot get the double click to work.
The Work Book opens at Sheet1 which is named Clients and has the client’s name in col A and the client’s sheet number in col B. I want the client to double click his name and have the code activate his sign in/out sheet. I can not get the double click to work. Can someone help me.
Attached is the code from the beginning of the program.
The Work Book opens at Sheet1 which is named Clients and has the client’s name in col A and the client’s sheet number in col B. I want the client to double click his name and have the code activate his sign in/out sheet. I can not get the double click to work. Can someone help me.
Attached is the code from the beginning of the program.
VBA Code:
Option Compare Text
Const BLANK = ""
'Private Sub Workbook_Open()
'Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
'Call GetClientNum
'End Sub
'Sub GetClientNum()
'End Sub
'MsgBox "get client name"
Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As Boolean)
Dim wks As Worksheet
If target.Column = 1 And _
target.Row >= 2 And _
target.Value <> "" Then
' The check above is used to ensure we are looking at a client cell.
Set wks = Worksheets(target.Offset(, 1).Value) 'this addresses the client sheet name
' Set CANCEL to TRUE so Excel will not try to handle the double-click event.
Cancel = True
'Set wks = Worksheets(target.Offset(, 1).Value)
wks.Activate
Call xit
End Sub