dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,352
- Office Version
- 365
- 2016
- Platform
- Windows
I have a table on my spreadsheet called css_quote that records information about jobs, where column F records the staff required. If anything is entered in this cell that is greater then 1, I need an input box to appear asking how many cars are needed. I then need this number put into column L for the row.
This is my worksheet_change event for the sheet that has the table. Can someone help me with the vba to achieve the above please?
This is my worksheet_change event for the sheet that has the table. Can someone help me with the vba to achieve the above please?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Quoting.Unprotect Password:=ToUnlock
Dim ans As String
'code to enter allow organisation to be entered if other is selected
If Not Intersect(Target, Me.Range("B7")) Is Nothing Then
If LCase(Me.Range("B7").Value) = "other" Then
ans = InputBox("Please enter organisation.", , Me.Range("B7").Value)
If ans <> "" Then
Range("B7").Value = ans
End If
End If
End If
If Selection.Count = 1 Then
'If Not Intersect(Target, Range("B7")) Is Nothing Then
' Workbooks.Open ThisWorkbook.Path & "\" & "Client_list.xlsm"
' End If
End If
If Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
'
On Error GoTo App_Events
If Not Intersect(Target, Range("A:A,B:B")) Is Nothing Then
Select Case Target.Column
Case 1
If Target.Value < Date Then
If MsgBox("This input is older than today. Are you sure that is what you want?", vbYesNo) = vbNo Then
Target.Value = ""
End If
End If
Case 2
If LCase(Target.Value) = LCase("Activities") Then
Do
ans = InputBox("Please enter the Activities cost." & _
vbCrLf & "************************************" & vbCrLf & _
"To change an activity cost, select Activities from the Service list again.")
If ans <> "" Then
Cells(Target.Row, "M") = ans
Exit Do
Else
MsgBox ("You must enter a Activities cost.")
End If
Loop
End If
End Select
End If
' If Selection.Count = 1 Then
' If Not Intersect(Target, Me.ListObjects("CSS_Quote").ListColumns(1).Range) Is Nothing Then
' MsgBox "hello"
' End If
' End If
App_Events:
Application.EnableEvents = True
Quoting.Protect Password:=ToUnlock
End Sub