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 6691557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:45:56+00:00 2026-05-26T05:45:56+00:00

Here is a website with a list of books in a relatively simple format.

  • 0

Here is a website with a list of books in a relatively simple format.

http://www.autism-resources.com/autism.bib
I copied the list into excel, and each group of % symbols is a listing for a book, with different details like keywords and such. for instance %T = titles.
I want to create a macro to search through the list and copy every row that starts with “% whatever marker i choose” to the B column

Here is code I found and changed to do pretty close to what I want, except I keep getting an error.

Sub SearchForString()

Dim LSearchRow As Integer
Dim LCopyToRow As Integer
Dim celltxt As String

On Error GoTo Err_Execute

LSearchRow = 1

LCopyToRow = 1

While Len(Range("A" & CStr(LSearchRow)).Value) > 0

    celltxt = ActiveSheet.Range("A" & CStr(LSearchRow)).Value

    If InStr(1, celltxt, "%T") > 0 Then

        Cells("A" & CStr(LSearchRow)).Select
        Selection.Copy

        Cells("B" & CStr(LCopyToRow)).Select
        ActiveCell.Paste

        LCopyToRow = LCopyToRow + 1

    End If

    LSearchRow = LSearchRow + 1

Wend

Application.CutCopyMode = False
Range("A1").Select

MsgBox "All matching data has been copied."

Exit Sub

Err_Execute:
    MsgBox "An error occurred."

End Sub

Also, I believe the:

While Len(range....) > 0    

is set to keep looping until the active cell is empty, but the data is separated by a blank row for each book. I can go through and delete the empty rows, but is there a way to get around that with code?

  • 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-05-26T05:45:56+00:00Added an answer on May 26, 2026 at 5:45 am

    See if this works for you. I used a Web Query and downloaded the data to A1 on sheet “Raw”

    'simple struct to describe each line of data
    Public Type InfoLine
        Tag As String
        Data As String
    End Type
    
    Sub Tester()
    
        Dim rw As Range, src As Range
        Dim dest As Range
        Dim line As String
        Dim numBlank As Integer
        Dim HadContent As Boolean
        Dim info As InfoLine
    
        Set src = ThisWorkbook.Worksheets("Raw").Range("A1")
        Set rw = ThisWorkbook.Worksheets("Books").Rows(1)
    
        Application.ScreenUpdating = False
    
        numBlank = 0
        'stop after 10 consecutive blank cells
        Do While numBlank < 10
            line = Trim(src.Value)
    
            If Len(line) > 0 Then
    
                numBlank = 0
                info = GetInfoLine(line)
    
                If info.Tag <> "" Then
    
                    Set dest = Nothing
                    Select Case info.Tag
                        Case "T": Set dest = rw.Cells(1)
                        Case "B": Set dest = rw.Cells(2)
                        Case "A": Set dest = rw.Cells(3)
                    End Select
    
                    If Not dest Is Nothing Then
                        HadContent = True
                        'does the cell already have content?
                        If Len(dest.Value) > 0 Then
                            'add new line after line break
                            dest.Value = dest.Value & Chr(10) & info.Data
                        Else
                            dest.Value = info.Data
                        End If
                    End If
    
                Else
                    'no tag - continues previous line (if captured)
                    If Not dest Is Nothing Then
                        dest.Value = dest.Value & " " & line
                    End If
                End If
            Else
                numBlank = numBlank + 1
                If numBlank = 1 And HadContent Then Set rw = rw.Offset(1, 0)
                HadContent = False
            End If
    
            Set src = src.Offset(1, 0)
        Loop
    
        Application.ScreenUpdating = True
    
    End Sub
    
    Function GetInfoLine(line As String) As InfoLine
        Dim rv As InfoLine
        If line Like "%*" Then
            rv.Tag = UCase(Trim(Mid(line, 2, InStr(1, line, " ", 0) - 2)))
            rv.Data = Trim(Mid(line, InStr(line, " ")))
        Else
            rv.Tag = ""
            rv.Data = line
        End If
        GetInfoLine = rv
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi deae the problem is this, here is my website URL http://pkbazaar.com When I
here is the website im talking about http://makeupbyarpi.com/portfolio.php you'll notice some of the images
Okay, so here's my problem: I have a list of members on a website,
I've designed a responsive website here: http://zarin.me/cce/ I've used Twitter Bootstrap for the responsive
I have set up a website here: http://liamwli.co.uk/ggsim On the bottom, there are 2
Could you please take a look at the harvard medical school website here http://hms.harvard.edu/
here is my website: http://kidscare.edu.vn When open it in IE9, the homepage switch to
I recently came across this website: http://studiostyles.info , which contains a list of color
<ol style=padding-top:0;> <li><a href=http://www.24hourfitness.com/membership/offers/specials.html?cm_mmc=Silverfox-_-SEM-_-Google-_-Branded?>24 Hour Fitness</a></li> <!-- open nested list --> <ul> <li>This website
I have a website (here: http://kitandmarcin.us ) with links to a variety of external

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.