kijato

Excel, VBA, Userform1

May 7th, 2020
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Sheets(KategoriComboBox.Text).Activate
  2.  
  3.  
  4. ' https://analystcave.com/excel-vba-listbox/
  5.  
  6. Private Sub UserForm_Activate()
  7.    
  8.     'Add all available sheet names to dropdown box
  9.    For Each wksCurrentSheet In Worksheets
  10.         ComboBox1.AddItem wksCurrentSheet.Name
  11.     Next wksCurrentSheet
  12.     ComboBox1.Text = Sheets(3).Name
  13.     'Sheets("<sheet Name>").Index
  14.    'Sheets("<sheet Name>").CodeName
  15.    
  16.     'ComboBox2.List = Range("A1:C5").Value
  17.    For Each head In Range("a1:c1")
  18.         ComboBox2.AddItem head.Value
  19.     Next head
  20.    
  21. End Sub
  22.  
  23. Private Sub ComboBox1_Change()
  24.    Sheets(ComboBox1.Text).Activate
  25. End Sub
  26.  
  27. Private Sub UserForm_Terminate()
  28.     Selection.AutoFilter Field:=Sheets("Munka3").Index
  29. End Sub
  30.  
  31. Private Sub TextBox1_Change()
  32.    'Selection.AutoFilter Field:=Sheets(ComboBox2.Text).Index, Criteria1:=TextBox1.Text
  33.   Selection.AutoFilter Field:=Sheets("Munka3").Index, Criteria1:=TextBox1.Text
  34. End Sub
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. Sub RemoveCarriageReturns()
  43.     Dim MyRange As Range
  44.     Application.ScreenUpdating = False
  45.     Application.Calculation = xlCalculationManual
  46.  
  47.     For Each MyRange In ActiveSheet.UsedRange
  48.         Debug.Print MyRange.Address
  49.         If 0 < InStr(MyRange, Chr(10) & Chr(10)) Then
  50.             MyRange = Replace(MyRange, Chr(10) & Chr(10), "")
  51.             Debug.Print "k"
  52.         End If
  53.         If Len(MyRange.Value) = InStr(MyRange, Chr(10)) Then
  54.             MyRange = Replace(MyRange, Chr(10), "")
  55.             Debug.Print "v"
  56.         End If
  57.     Next
  58.  
  59.     Application.ScreenUpdating = True
  60.     Application.Calculation = xlCalculationAutomatic
  61. End Sub
  62.  
  63.  
  64.  
  65. Private Sub ComboBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  66.     ComboBox1.RowSource = "Munka1!a1:c3"
  67.     Selection.AutoFilter Field:=1, Criteria1:=ComboBox1.Text
  68. End Sub
  69.  
  70. Private Sub CommandButton1_Click()
  71.     'Label1.Caption = ComboBox1.SelText
  72.    TextBox1.Text = TextBox1.Text & vbNewLine & ComboBox1.Text
  73. End Sub
  74.  
  75. Private Sub TextBox1_Change()
  76.     Range("d5").Value = TextBox1.Value
  77. End Sub
  78.  
  79. Private Sub UserForm_Initialize()
  80.     ComboBox1.Clear
  81.     TextBox1.MultiLine = True
  82. End Sub
Add Comment
Please, Sign In to add comment