+ Reply to Thread
Results 1 to 2 of 2

User form to Search Data and Insert

  1. #1
    Registered User
    Join Date
    12-20-2012
    Location
    Maldives
    MS-Off Ver
    Excel 2010
    Posts
    12

    User form to Search Data and Insert

    Hi i need this sample excel file macro to search data in userform and insert selected account code to C4 highlighted in Yellow.

    Userform should show the search results not in Excel sheet.



    Thank You
    Attached Files Attached Files
    Last edited by magnum4u; 01-23-2017 at 11:15 AM.

  2. #2
    Registered User
    Join Date
    12-20-2012
    Location
    Maldives
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: User form to Search Data and Insert

    I need this macro as UserForm thanks
    Sub SearchGL()
    Dim arrGL() As Variant
    Range("A8", "b" & Cells(Rows.CountLarge, "b").End(xlDown).Row).Clear
    arrGL = FindGL(CStr(Trim(Cells(4, 3))))
    Range("A8").Resize(UBound(arrGL, 2), UBound(arrGL)) = _
    WorksheetFunction.Transpose(arrGL)
    Columns("A:B").EntireColumn.AutoFit
    End Sub
    Private Function FindGL(GLNumber As String) As Variant
    Dim ws As Worksheet
    Dim FoundCell As Range
    Dim LastCell As Range
    Dim rngGL As Range
    Dim FirstAddr As String
    Dim arrName() As Variant

    Set ws = Worksheets("GL")
    Set rngGL = ws.Range("c1:c" & ws.Cells(Rows.CountLarge, "c").End(xlUp).Row)

    With rngGL
    Set LastCell = .Cells(.Cells.Count)
    End With

    Set FoundCell = rngGL.Find(What:=GLNumber, After:=LastCell, LookAt:=xlPart)

    If Not FoundCell Is Nothing Then
    FirstAddr = FoundCell.Address
    End If

    ReDim arrName(1 To 2, 1 To 1)
    Do Until FoundCell Is Nothing
    arrName(1, UBound(arrName, 2)) = FoundCell.Offset(0, -1)
    arrName(2, UBound(arrName, 2)) = FoundCell.Value

    ReDim Preserve arrName(1 To 2, 1 To UBound(arrName, 2) + 1)

    Set FoundCell = rngGL.FindNext(After:=FoundCell)
    If FoundCell.Address = FirstAddr Then
    Exit Do
    End If
    Loop
    FindGL = arrName
    End Function

+ 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. User form with search and update function with multiple column/Data
    By onyony34 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-08-2015, 03:05 AM
  2. VBA Coding to search a column for data entered in text box on my user form
    By cnkwasher in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2014, 03:11 PM
  3. VBA to Insert row & data from user form in list
    By CajunAg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2013, 06:04 PM
  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. User Form - Insert Row then Data
    By cooper1308 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2009, 08:38 PM
  6. user form data search
    By atakayd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-23-2007, 12:56 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