+ Reply to Thread
Results 1 to 10 of 10

Finding the nth non empty cell in a row and returning value to text box vba

Hybrid View

jimalya Finding the nth non empty... 07-22-2013, 04:33 PM
tigeravatar Re: Finding the nth non empty... 07-22-2013, 05:17 PM
jimalya Re: Finding the nth non empty... 07-22-2013, 07:47 PM
jimalya Re: Finding the nth non empty... 07-22-2013, 08:00 PM
jimalya Re: Finding the nth non empty... 07-22-2013, 08:20 PM
tigeravatar Re: Finding the nth non empty... 07-23-2013, 11:32 AM
jimalya Re: Finding the nth non empty... 07-23-2013, 11:45 AM
tigeravatar Re: Finding the nth non empty... 07-23-2013, 12:40 PM
jimalya Re: Finding the nth non empty... 07-23-2013, 01:36 PM
tigeravatar Re: Finding the nth non empty... 07-23-2013, 01:41 PM
  1. #1
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    Hey tigeravatar,
    I'm getting an object variable not set in this line:
    For Each CheckCell In Intersect(ActiveRecord.EntireRow, Range("H:O"))

  2. #2
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. finding a text string and returning a Y or N
    By wilksy in forum Excel General
    Replies: 3
    Last Post: 05-11-2011, 03:38 AM
  2. finding max value and returning text in different column same row
    By Mark6277 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2009, 01:18 PM
  3. Replies: 6
    Last Post: 07-15-2009, 07:44 AM
  4. Finding text in a list, and returning the row next to it.
    By Hejl82 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-22-2008, 02:26 PM
  5. Finding next empty empty cell in a range of columns
    By UncleBun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2006, 07:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1