EAF #37 - Excel VBA Loop to Find Records Matching Search Criteria

ExcelTricksforSports · 402K views · 2013 · 11:35

Open on YouTube

Python, Ruby & scripting languagesEducation & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it as the tutorial they followed for a VBA search-and-copy loop, and then ask questions when their adapted version pastes nothing or returns one row.

Recommended by 1 people across 1 different months, 2015 to 2017.

What it is

A short 2013 screencast from the ExcelTricksforSports channel that shows how to write an Excel 2010 VBA procedure which loops through a worksheet database and copies every record matching a search value into a results sheet. It walks through declaring variables, clearing old results and pasting matches.

What people said

Recommends maxthackray · 2016-01 · Stack Overflow · on “Cross Referencing Data in Excel”

Hi @beutler . I have figured out the full code for my problem. This video really helped me get on the right path. Took a lot of testing and trial and error but this video got me well on the right path. [this video]

Cites user1664305 · 2015-05 · Stack Overflow · on “Quicker way to filter out data based on a particular value”

I am working with a workbook that currently has 3 sheets. The first sheet is an overview where the filtered data will appear. Cell D11 has the color that I am looking for. Upon entering the color cells F3:I27 Populate with information like color, shape, number and animal. C2C-Tracker2 [LINK] I would use a Pivot Table for this, however, I have another set of data in K3:M27 . This data is pulled from another sheet within the workbook with a similar function. The formula that I am using is: =IFERROR(INDEX(cases!A:A,SMALL(IF(EXACT($D$3,cases!$C:$C),ROW(cases!$C:$C)-ROW($F$1)+1),ROW(1:1))),"") Of course it is entered using CTRL + SHIFT + ENTER for it to work properly. I tried using a VBA Macro th

Cites Mcodewick · 2017-09 · Stack Overflow · on “Macro for Searching large database for Assembly number, pasting results in another Sheet”

I'm new to VBA coding, but I basically wanted create a similar function to this youtube video: [this video] I have two sheets of interest, Stencils and Search. I'd like to be able to type the assembly number into the Search tab, press a macro button, have it search through the Stencils tab and paste the data it finds matching the assembly number. Possibly I might need to change how I define my variables, not sure. I can run the code without any errors. The code clears the contents of the destination cells as it should. However, it does not paste anything. Sub findstencil() '1. declare variables '2. clear old search results '3. find records that match search criteria and paste them Dim assembly As

Cites StephanieV · 2017-11 · Stack Overflow · on “VBA Loop - Only 1 Result”

I am using this tutorial to write a VBA Loop to search for a value in a column and pulls all rows with the criteria value. [this video] It is running but it takes about 5 minutes to run and in the end I only get 1 result(row) when I should be getting thousands. Sub finddata() '1.Declare Variables '2.Find Records that match criteria and paste them into new worksheet Dim customcode As String Dim finalrow As Long Dim i As Long customcode = Sheets("Sheet2").Range("A1").Value finalrow = Sheets("Raw Data").Range("A252800").End(xlUp).Row For i = 1 To finalrow If Cells(i, 46) = customcode Then Range(Cells(i, 1), Cells(i, 102)).Copy Worksheets("Sheet1").Range("A1").PasteSpecial End If Next i End Sub Any h