+ Reply to Thread
Results 1 to 2 of 2

Modding search engine with row in stead of cell

  1. #1
    Registered User
    Join Date
    02-10-2016
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    7

    Modding search engine with row in stead of cell

    Hi,

    I recently started using macro's to make my database searching job easier. This morning i stumbled upon a piece of 'search engine' code that can be used in excel, which works great.

    Except, i have a database with columns from A to U, and the code i used from this forum only copies one column to the search page.

    I think it is this piece of the code which needs to be modified:
    arrTool(2, UBound(arrTool, 2)) = FoundCell.Offset(0, 1)
    arrTool(1, UBound(arrTool, 2)) = FoundCell.Value

    The FoundCell.Offset(0,1) only takes the value with offset (0,1), while i need the whole row.
    How can i modify this?

    Thanks in advance!



    This is the code:



    Sub SearchDM()
    Dim arrDM() As Variant
    Range("A7", "U" & Cells(Rows.CountLarge, "U").End(xlDown).Row).Clear
    arrTool = FindDM(CStr(Trim(Cells(2, 2))))
    Range("I7").Resize(UBound(arrTool, 2), UBound(arrTool)) = _
    WorksheetFunction.Transpose(arrTool)
    End Sub
    Private Function FindDM(PartNumber As String) As Variant
    Dim ws As Worksheet
    Dim FoundCell As Range
    Dim LastCell As Range
    Dim rngDM As Range
    Dim FirstAddr As String
    Dim arrTool() As Variant

    Set ws = Worksheets("All")
    Set rngDM = ws.Range("I2:I" & ws.Cells(Rows.CountLarge, "I").End(xlUp).Row)

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

    Set FoundCell = rngDM.Find(What:=PartNumber, After:=LastCell, LookAt:=xlPart)


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

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

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

    Set FoundCell = rngDM.FindNext(After:=FoundCell)
    If FoundCell.Address = FirstAddr Then
    Exit Do
    End If
    Loop
    FindDM = arrTool
    End Function

  2. #2
    Registered User
    Join Date
    02-10-2016
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    7

    Re: Modding search engine with row in stead of cell

    I tried to use the resize command after offset, like this:

    arrTool(2, UBound(arrTool, 2)) = FoundCell.Offset(0, 1).Resize(,2)

    But, now I get 'Type Mismatch' in the line:
    Range("I7").Resize(UBound(arrTool, 2), UBound(arrTool)) = _ WorksheetFunction.Transpose(arrTool)

    Does anyone has an idea how I can select the entire row from A to U and paste it in stead of 1 column?

+ 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. Search Engine VBA
    By aeschylus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2015, 11:14 AM
  2. Search Engine
    By kmcclintic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2014, 07:56 AM
  3. VBA search engine with auto fill cell and for searching in 3 column
    By avogadrow in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2014, 05:36 PM
  4. Replies: 2
    Last Post: 02-15-2014, 12:03 AM
  5. Display expanded formula in cell in stead of cell references
    By vnr2583 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-24-2013, 10:06 PM
  6. Search engine
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-11-2009, 01:16 PM
  7. Developing Search Engine to search several Excel sheets
    By cruiser102 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2009, 09:30 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