Hey tigeravatar,
I'm getting an object variable not set in this line:
![]()
For Each CheckCell In Intersect(ActiveRecord.EntireRow, Range("H:O"))
Hey tigeravatar,
I'm getting an object variable not set in this line:
![]()
For Each CheckCell In Intersect(ActiveRecord.EntireRow, Range("H:O"))
Here's my entire code if this helps.
![]()
Option Explicit Dim rSource As Range Dim lFld As Long Dim oCtrl As MSForms.Control Dim sCrit As String Private Sub ComboBox1_Change() sCrit = Me.ComboBox1.Value lFld = 1 End Sub Private Sub ComboBox2_Change() sCrit = Me.ComboBox2.Value lFld = 2 End Sub Private Sub ComboBox3_Change() sCrit = Me.ComboBox3.Value lFld = 3 End Sub Private Sub ComboBox4_Change() sCrit = Me.ComboBox4.Value lFld = 4 End Sub Private Sub ComboBox5_Change() sCrit = Me.ComboBox5.Value lFld = 5 End Sub Private Sub CommandButton1_Click() Dim CheckCell As Range Dim ActiveRecord As Range Dim arrData(1 To 17, 1 To 2) As String Dim DataIndex As Long Dim i As Long 'Your code to filter the data and/or adjust the active record goes here Rows("1:1").AutoFilter With frmFilter ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=1, Criteria1:="*" & ComboBox1.Value ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=2, Criteria1:="*" & ComboBox2.Value ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=3, Criteria1:="*" & ComboBox3.Value ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=4, Criteria1:="*" & ComboBox4.Value ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=5, Criteria1:="*" & ComboBox5.Value ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=6, Criteria1:="*" & ComboBox6.Value ActiveSheet.Range("$A$1:$X$200").AutoFilter Field:=7, Criteria1:="*" & ComboBox7.Value End With Dim r As Range Set r = Intersect(ActiveSheet.AutoFilter.Range, Range("A:A")) frmFilter.txtOptionEnd.Value = Application.WorksheetFunction.Subtotal(103, r) - 1 'Now you are working with the active record 'You can use Intersect to determine which columns to check 'This will check columns H:O for the row of the active record For Each CheckCell In Intersect(ActiveRecord.EntireRow, Range("H:O")) If Len(CheckCell.Text) > 0 Then DataIndex = DataIndex + 1 arrData(DataIndex, 1) = Cells(1, CheckCell.Column).Text arrData(DataIndex, 2) = CheckCell.Text End If Next CheckCell For i = 1 To DataIndex Controls("txtWC" & i).Text = arrData(i, 1) Controls("txtNotes" & i).Text = arrData(i, 2) Next i End Sub Private Sub CommandButton2_Click() Unload frmFilter frmFilter.Show UserForm_Initialize End Sub Private Sub CommandButton4_Click() Unload Me End Sub Private Sub UserForm_Initialize() Rows("1:1").AutoFilter Dim V1, V2, V3, V4, V5, V6, V7 With Workbooks("Notes").Sheets("data") V1 = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row).Value V2 = .Range("B2:B" & .Range("A" & .Rows.Count).End(xlUp).Row).Value V3 = .Range("C2:C" & .Range("A" & .Rows.Count).End(xlUp).Row).Value V4 = .Range("D2:D" & .Range("A" & .Rows.Count).End(xlUp).Row).Value V5 = .Range("E2:E" & .Range("A" & .Rows.Count).End(xlUp).Row).Value V6 = .Range("F2:F" & .Range("A" & .Rows.Count).End(xlUp).Row).Value V7 = .Range("G2:G" & .Range("A" & .Rows.Count).End(xlUp).Row).Value End With With frmFilter Call AddToList(V1, .ComboBox1) Call AddToList(V2, .ComboBox2) Call AddToList(V3, .ComboBox3) Call AddToList(V4, .ComboBox4) Call AddToList(V5, .ComboBox5) Call AddToList(V6, .ComboBox6) Call AddToList(V7, .ComboBox7) End With End Sub Sub AddToList(myRange, myBox As Control) Dim e Debug.Print myBox With CreateObject("scripting.dictionary") .comparemode = 1 For Each e In myRange If Not .exists(e) Then .Add e, Nothing Next If .Count Then myBox.List = Application.Transpose(.keys) End With End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks