Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:15:25+00:00 2026-06-10T02:15:25+00:00

I am making a macro that will search though a list and find all

  • 0

I am making a macro that will search though a list and find all the entries in a column that has spectraseven at the first. This will be to copy these records to sheet for each entry.

With the code so far it fails with:

Run-time error ‘1004’: Application-defined or object-defined error.

Sub testWild()
startCell = 0
Dim FoundCell As Range
Dim LastCell As Range
Dim FirstAddr As String
cellRange = "A1:A20"
topCount = startCell
With Range("A1:A20")
Set LastCell = .Cells(.Cells.Count)
End With
Dim findString As String 
findString = "spectraseven*"
 Set FoundCell = Range(cellRange).Find(what:=findString, after:=LastCell)



If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
End If
Do Until FoundCell Is Nothing
    Debug.Print FoundCell.Address
Set FoundCell = Range(cellRange).FindNext(after:=FoundCell)

Count = FoundCell.Row
    Set FoundCell = Range(cellRange).FindNext(after:=FoundCell)

 --->   Sheets(1).Range("a" & topCount) = Sheets(1).Range("e" & Count)
    topCount = topCount + 1



If FoundCell.Address = FirstAddr Then
    Exit Do
End If
Loop
End Sub

The arrow points to the error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:15:27+00:00Added an answer on June 10, 2026 at 2:15 am

    You set startCell equal to 0.

    You then set topCount = startCell

    You don’t do anything else with topCount before starting the loop.

    Therefore, this:

    Sheets(1).Range("a" & topCount) = Sheets(1).Range("e" & Count)
    

    Evaluates to

    Sheets(1).Range("a0") = Sheets(1).Range("e" & FoundCell.Row)
    

    There is no such thing as cell A0. Try starting startCell at 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I needed the HIDWORD macro for a program I'm making and found this one
I am making my first Powerpoint 2007 macro and I am having a bit
First let me explain why I am asking this question so its clear that
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any
Before making a commit, I prefer to run all hundred-something unit tests in my
I'm designing/building a system of classes that all derive from a single base class.
I am making a very simple platform independent(at least that's the plan) console app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.