Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim s As String ' str is not good for a name of variable because Str() is the internal VBA function
Dim cboTemp As ComboBox
Set cboTemp = Me.QuoteCombo
On Error GoTo errHandler
If Target.Validation.Type = 3 Then
'if the cell contains
'a data validation list
Cancel = True
Application.EnableEvents = False
'get the data validation formula
s = Target.Validation.Formula1
s = Mid(s, 2)
With cboTemp
'show the combobox with the list
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 15
.Height = Target.Height + 5
.ListFillRange = s
.LinkedCell = Target.Address
.Visible = True
End With
cboTemp.Activate
'open the drop down list automatically
cboTemp.DropDown
End If
errHandler:
Application.EnableEvents = True
End Sub
Private Sub QuoteCombo_LostFocus()
On Error Resume Next
With Me.QuoteCombo
.Visible = False
Call Worksheet_Change(Range(.LinkedCell))
.LinkedCell = ""
.ListFillRange = ""
.Value = ""
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'--> Setting, change to suit
Const RangeToFit = "B24:D10000,Y24:Z10000,AF24:AF10000,AZ24:AZ10000,BD24:BD10000,BF24:BS10000"
'<--
' See the post 38, this code solves issue of a column size fitting when:
' 1. Not active cell below the row 23 in active column has a lengthy text (minimun width is not enough)
' 2. Width of active column is less than it's required for the point 1 (being resized manually, for example)
' 3. Length of a text in active cell is less than lenght of the cell in point 1
' Also this code auto resizes a series of columns at deleting/copying group of cells
Dim OldWidth As Double, Col As Range
If Intersect(Target, Range(RangeToFit)) Is Nothing Then Exit Sub
For Each Col In Intersect(Target.EntireColumn, Range(RangeToFit)).Columns
OldWidth = Col.ColumnWidth
Col.AutoFit
If Col.ColumnWidth < OldWidth Then Col.ColumnWidth = OldWidth
If Col.ColumnWidth < 18 Then Col.ColumnWidth = 18
Next
' Other code
Dim response
If Not Intersect(Target, Range("C24:C1000")) Is Nothing And ActiveSheet.Range("B3") <> 1 And Target.Cells.Count = 1 Then
If UCase(Target) Like "GAL*" Or UCase(Target) Like "SA-36*" Or UCase(Target) Like "SA-45*" Then
response = MsgBox("YOU MAY NEED CONTINUOUS CHAIN. SELECT *YES* TO STOP FUTURE WARNINGS OR *NO* TO CONTINUE WARNINGS.", vbYesNo)
If response = vbYes Then
ActiveSheet.Range("B3") = 1
Else
Exit Sub
End If
End If
End If
End Sub