Results 1 to 22 of 22

A better way to store/retrieve bulk data?

Threaded View

  1. #5
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: A better way to store/retrieve bulk data?

    Ok, take a look at the attached workbook to test this out. I am confident this can greatly speed up your code...

    Since you can't upload an example, i put together the function and a simple test Sub to show it in action. Open the workbook, enable the macros and press the button to test the function.
    You can step through the code to see it working. Press Alt+F8 to see the macro, select "test" and press "Step Into". Press F8 to take each step.

    I have a message box pop up to show the results, and i also list them in the sheet in the A column. I think you had a different final step, but maybe this will be something you can edit to meet your needs.


    OPTION EXPLICIT
    Sub test()
    
    Dim test As Range, hit As Range, x As Variant
    
    Set test = findMatchRange(ThisWorkbook.Worksheets("Sheet1").Cells.Find("Test Data").EntireColumn, ThisWorkbook.Worksheets("Sheet1").Cells.Find("Test Value").Offset(0, 1).Value)
    
    x = ""
    For Each hit In test
        x = x & hit.Value
    Next hit
    MsgBox (x)
    
    For Each hit In test
       ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = hit.Value
       
    Next hit
    
    End Sub
    
    
    Function findMatchRange(searchRange As Range, lookFor As String) As Range
    
    Dim c As Range, matches As Range, hit As Range
    Dim firstAddress As String
    
    With searchRange
      Set c = .Find(what:=lookFor)
      If Not c Is Nothing Then
        Set matches = c
        firstAddress = c.Address
        Do
         Set matches = Union(matches, c)
         Set c = .FindNext(c)
        Loop While c.Address <> firstAddress
      End If
    End With
    
    Set findMatchRange = matches
    
    End Function
    Attached Files Attached Files
    Last edited by GeneralDisarray; 05-28-2013 at 04:34 PM.

Thread Information

Users Browsing this Thread

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

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