Results 1 to 6 of 6

List Results in Userform

Threaded View

danweeks20 List Results in Userform 02-04-2016, 03:56 PM
AlphaFrog Re: List Results in Userform 02-04-2016, 05:08 PM
danweeks20 Re: List Results in Userform 02-04-2016, 05:27 PM
mike7952 Re: List Results in Userform 02-06-2016, 03:25 AM
danweeks20 Re: List Results in Userform 02-08-2016, 06:21 PM
mike7952 Re: List Results in Userform 02-08-2016, 08:50 PM
  1. #1
    Registered User
    Join Date
    09-27-2010
    Location
    Christchurch, NZ
    MS-Off Ver
    Excel 2003
    Posts
    23

    List Results in Userform

    Hi all,

    I have done my best to create the worksheet attached making some sacrifices at the same time, for example on UserForm1 I was unable to get this to create a sequential reference number using "SBCRXXXX" so have gone for a random, which is ok as long as it doesn't repeat.

    My biggest problem at present is USERFORM3, that the search option whilst it works by giving a row number doesn't display all the information I want from the row. I have so far spent a number of days using different tips and tricks I could find to get this working in its current state, is anyone able to please have a look at the coding and see why this might be?

    Private Sub CommandButton1_Click()
    'SEARCH

    Dim Cnt As Long
    Dim Col As Variant
    Dim FirstAddx As String
    Dim FoundMatch As Range
    Dim LastRow As Long
    Dim R As Long
    Dim StartRow As Long
    Dim Wks As Worksheet

    StartRow = 2
    Set Wks = Sheets(1)

    Col = ComboBox1.ListIndex + 1
    If Col = 0 Then
    MsgBox "Please choose a category to search."
    Exit Sub
    End If

    If TextBox1.Text = "" Then
    MsgBox "Please enter a search term."
    TextBox1.SetFocus
    Exit Sub
    End If

    LastRow = Wks.Cells(Rows.Count, Col).End(xlUp).Row
    LastRow = IIf(LastRow < StartRow, StartRow, LastRow)

    Set rng = Wks.Range(Wks.Cells(2, Col), Wks.Cells(LastRow, Col))

    Set FoundMatch = rng.Find(What:=TextBox1.Text, _
    After:=rng.Cells(1, 1), _
    LookAt:=xlWhole, _
    LookIn:=xlValues, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)

    If Not FoundMatch Is Nothing Then
    FirstAddx = FoundMatch.Address
    ListView1.ListItems.Clear

    Do
    Cnt = Cnt + 1
    R = FoundMatch.Row
    ListView1.ListItems.Add Index:=Cnt, Text:=R
    For Col = 1 To 26
    Set C = Wks.Cells(R, Col)
    ListView1.ListItems(Cnt).ListSubItems.Add Index:=Col, Text:=C.Text
    Next Col
    Set FoundMatch = rng.FindNext(FoundMatch)
    Loop While FoundMatch.Address <> FirstAddx And Not FoundMatch Is Nothing
    SearchRecords = Cnt
    Else
    ListView1.ListItems.Clear
    SearchRecords = 0
    MsgBox "No match found for " & TextBox1.Text
    End If

    End Sub

    Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)

    End Sub

    Private Sub UserForm_Activate()

    Dim C As Long
    Dim I As Long
    Dim R As Long
    Dim Wks As Worksheet

    With ListView1
    .Gridlines = True
    .View = lvwReport
    .HideSelection = False
    .FullRowSelect = True
    .HotTracking = True
    .HoverSelection = False
    .ColumnHeaders.Add Text:="Job Sheet", Width:=64
    End With

    Set Wks = Sheets(1)

    For C = 1 To 13
    ListView1.ColumnHeaders.Add Text:=Wks.Cells(1, C).Text
    ComboBox1.AddItem Wks.Cells(8, C).Text
    Next C

    End Sub

    Thank you very much in advance,

    Daniel
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Userform Combobox - select from list, store this as default each time userform loads
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2014, 07:48 AM
  2. Userform Results
    By MKnuep in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2014, 01:12 PM
  3. UserForm help - display list of open workbooks except workbook userform code is in
    By kensweep in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-09-2014, 12:26 PM
  4. Replies: 3
    Last Post: 10-30-2013, 09:18 AM
  5. Userform Search Function Autofilter Results and Repopulate Userform
    By cindy71 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-16-2012, 03:46 PM
  6. UserForm to search sheet, show results on separate userform?
    By egemenkepekci in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2010, 01:06 PM
  7. Replies: 2
    Last Post: 08-18-2006, 05:28 AM

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