+ Reply to Thread
Results 1 to 2 of 2

Check part of cell for data

Hybrid View

  1. #1
    Mike K.
    Guest

    Check part of cell for data

    I need to check the cells in a column to see if any of the cells contain
    certain data. For example:

    Apple Pie
    Apple and Berry Cobbler
    Berry Jam
    Apple Jam

    I would need to be able to run the macro to check if the cell contained
    Berry to then list each cell that fit the criteria. I've got my Loop to run
    through the column and transfer the data to another column but need to code
    for checking within each cell. Any help would be great. Thanks!
    --
    Mike
    M2K Computer Consulting
    www.m2kcomputers.com

  2. #2
    Registered User
    Join Date
    06-20-2006
    Location
    Leeds, England
    Posts
    16
    Try something along the line of:

    Sub berry()
    Dim strToFind
    strToFind = "berry"
    For r = 1 To 4
    If InStr(1, Cells(r, 1), strToFind, vbTextCompare) > 0 Then Cells(r, 3) = Cells(r, 1)
    Next r
    End Sub

    This assumes the list is in column 1 and the cell contents needs copying to column 3.


    Quote Originally Posted by Mike K.
    I need to check the cells in a column to see if any of the cells contain
    certain data. For example:

    Apple Pie
    Apple and Berry Cobbler
    Berry Jam
    Apple Jam

    I would need to be able to run the macro to check if the cell contained
    Berry to then list each cell that fit the criteria. I've got my Loop to run
    through the column and transfer the data to another column but need to code
    for checking within each cell. Any help would be great. Thanks!
    --
    Mike
    M2K Computer Consulting
    www.m2kcomputers.com

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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