+ Reply to Thread
Results 1 to 2 of 2

Populate a textbox on Userform with data from a filtered range using VBA

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Populate a textbox on Userform with data from a filtered range using VBA

    Hi

    I have a sheet which is filtered and I want to populate textboxes on a userform with data from a selected row of the filtered sheet.

    I have identified the RowNo of visible cells I want populating, but the code I have below gives me a 'Could not set the Value property. Type mismatch.' error.

    Can someone help me understand what I am doing wrong?

    Thanks

    Sub PrintData()
        Dim RowNo As Long
        
        RowNo = Sheets("Module Data 2").Range("L2").Value
        With Sheets("Inventory")
        
        txt1.Value = Sheets("Inventory").Cells(1, RowNo).SpecialCells(xlCellTypeVisible).Value
        'TextBox6.Value = .Range("B" & RowNo).SpecialCells(xlCellTypeVisible)
        'TextBox11.Value = .Range("C" & RowNo).SpecialCells(xlCellTypeVisible)
    
        
        End With
        
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Populate a textbox on Userform with data from a filtered range using VBA

    You don't need to worry about the filter because you can only select the visible rows

    Textbox6.value = range("B" & Selection.Row).value
    Textbox7.value = range("C" & Selection.Row).value
    Elegant Simplicity............. Not Always

+ 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. Trying to populate a userform combobox from a userform textbox
    By jtemp57 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2014, 03:33 PM
  2. [SOLVED] vba userform calendar to populate textbox in another userform
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2012, 01:43 PM
  3. [SOLVED] populate userform with filtered data
    By crossy5575 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2012, 11:47 AM
  4. VBA UDF to populate textbox in UserForm
    By grcaz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2012, 08:03 AM
  5. Userform Textbox to populate with
    By Julesdude in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-12-2010, 10:49 AM

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