+ Reply to Thread
Results 1 to 4 of 4

User form Search Not Working When Sheet is Changed

Hybrid View

  1. #1
    Registered User
    Join Date
    04-11-2016
    Location
    Ghana
    MS-Off Ver
    2007
    Posts
    32

    User form Search Not Working When Sheet is Changed

    I have a an Excel workbook with 3 sheets - Sheet1- ProcessedPV, Sheet2- Examined Staff and Sheet3. I have used sheet3 as login interface and intend to hide the other two sheets. I have a userform that searches sheet1 and displays data stored in sheet1 into a listbox. My challenge is, whenever I hide sheet1 and display the userform on sheet3, my userform does not respond to the search command unless I display the userform on sheet1. Attached is my file
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: User form Search Not Working When Sheet is Changed

    Private Sub CommandButton9_Click()
    Dim J As Long, WS As Worksheet
    Set WS = Worksheets("PROCESSEDPV")
    'Dim varTotal As Integer
    'Dim varRow As Integer
    'Dim x As Integer
    'x = ListBox1.ListCount
    'On Error Resume Next
    Me.ListBox1.AddItem
    For a = 1 To 10
    Me.ListBox1.List(0, a - 1) = Sheet1.Cells(1, a)
    Next a
    Me.ListBox1.Selected(0) = True
    If TextBox10.Value = "" Or TextBox11.Value = "" Then
    MsgBox "Please Choose Date", vbCritical, ""
    Exit Sub
    End If
     If CDate(TextBox10.Value) > CDate(TextBox11.Value) Then
        MsgBox "The Start Date Can Not Be Bigger Than The End Date.", vbCritical, ""
        Exit Sub
        End If
    ListBox1.Clear
    For J = 2 To Worksheets("PROCESSEDPV").Range("J" & Rows.Count).End(xlUp).Row
    If CDate(WS.Cells(J, "J").Value) >= CDate(TextBox10.Value) And CDate(WS.Cells(J, "J").Value) <= CDate(TextBox11.Value) Then
    With ListBox1
        .AddItem WS.Cells(J, 1).Value
        .List(.ListCount - 1, 1) = WS.Cells(J, 2).Value
        .List(.ListCount - 1, 2) = WS.Cells(J, 3).Value
        .List(.ListCount - 1, 3) = WS.Cells(J, 4).Value
        .List(.ListCount - 1, 4) = WS.Cells(J, 5).Value
        .List(.ListCount - 1, 5) = WS.Cells(J, 6).Value
        .List(.ListCount - 1, 6) = WS.Cells(J, 7).Value
        .List(.ListCount - 1, 7) = VBA.Format(WS.Cells(J, 8).Value, "#,##0.00")
        .List(.ListCount - 1, 8) = WS.Cells(J, 9).Value
        .List(.ListCount - 1, 9) = WS.Cells(J, 10).Value
    End With
    End If
    Next J
    J = Empty
    'For varRow = 0 To ListBox1.ListCount - 1
    'varTotal = Val(varTotal) + Val(ListBox1.Column(7, varRow))
    'Next
    'End With
    'TextBox13 = VBA.Format(varTotal, "#,##00.00")
    Label21 = ListBox1.ListCount
    End Sub
    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    04-11-2016
    Location
    Ghana
    MS-Off Ver
    2007
    Posts
    32

    Re: User form Search Not Working When Sheet is Changed

    Wow that's great Leo. It worked like magic. Am most grateful bro. God bless!!!

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: User form Search Not Working When Sheet is Changed

    no thanks,

    if you have no more questions, please mark the case as solved

    Kind regards
    Leo

+ 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. [SOLVED] Search and insert values in sheet from user form
    By sabeelahmedks in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2018, 05:39 AM
  2. Search and Edit Form, Search not working correctly
    By rob_h in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2017, 03:48 PM
  3. Create User form to perform search using multiple search criteria
    By cherias in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2015, 06:16 AM
  4. [SOLVED] User Form to execute search and return all values to the user form for editing
    By allwrighty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2013, 10:40 PM
  5. Replies: 4
    Last Post: 03-21-2013, 10:02 AM
  6. how to use VBA to search and return search result in the user form
    By pearlynie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2013, 07:58 AM
  7. Search User Form not working -vb reference? pls hlp
    By Ehlie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-11-2010, 05:45 PM

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