Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.29 KB | None | 0 0
  1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  2.     If Selection.Count = 1 Then
  3.          
  4.         If Not Intersect(Target, Range("A:A")) Is Nothing Then
  5.              
  6.             Dim cb As Object
  7.             Dim combineRange As Range
  8.             Dim boolStr As String
  9.             Dim floatStr As String
  10.             Dim booleanRange As Range
  11.             Dim floatRange As Range
  12.            
  13.             Dim bRow As Integer
  14.             bRow = Worksheets("DEF_BOOLEAN").Cells(Rows.Count, 1).End(xlUp).Row
  15.            
  16.             Dim fRow As Integer
  17.             fRow = Worksheets("DEF_FLOAT").Cells(Rows.Count, 1).End(xlUp).Row
  18.  
  19.             boolStr = "A2:A" & bRow
  20.             floatStr = "A2:A" & fRow
  21.            
  22.             Set booleanRange = Worksheets("DEF_BOOLEAN").Range(boolStr)
  23.             Set floatRange = Worksheets("DEF_FLOAT").Range(floatStr)
  24.            
  25.             Set combineRange = Worksheets("FT_CASE_xx").Range(booleanRange.Address & ":" & floatRange.Address)
  26.             Set cb = Worksheets("FT_CASE_xx").OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, DisplayAsIcon:=False, Left:=Target.Left, Top:=Target.Top, Width:=Target.Width, Height:=Target.Height).Object
  27.             cb.ListFillRange = combineRange
  28.        
  29.         End If
  30.     End If
  31. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement