+ Reply to Thread
Results 1 to 8 of 8

Current code searches entire worksheet, need to search just A column of multiple workbooks

  1. #1
    Registered User
    Join Date
    03-07-2017
    Location
    Stockport, England
    MS-Off Ver
    2007
    Posts
    91

    Current code searches entire worksheet, need to search just A column of multiple workbooks

    Hi Guys,

    Merry Christmas to all and Happy New Year. Struggling to get a bit of code to search just column A for numbers only and then display what is offset from what it finds. This is the code I have used for specific searches such as "SM" and "DP". I have done a test search for the number "1" but it brings back everything with a 1 in it in every column. I have also tried changing the range to "A16:A36" but that I get the same result. Any and all advise very welcome.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    Hi Mark Dynes ,
    Best wished to you in the New Year also.
    This is probably your problem:

    Set rFound = wks.Cells.FindNext(After:=rFound)

    This will find the next with the same search criteria as before, but .Cells returns a Range object consisting of the entire cells in the worksheet, so that is the range that will then be further searched.

    You probably want to replace that with

    Set rFound = wks.Range("A:A").FindNext(After:=rFound)

    Alan
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    Quote Originally Posted by Mark Dynes View Post
    Please Login or Register  to view this content.
    What do you need it for ?



    Edit:

    try:
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 12-29-2017 at 03:55 PM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    If you want to search a range for numeric values try taking a look at SpecialCells.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,217

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    Why not upload a sample file so that we can assist in the best possible code for your scenario...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    03-07-2017
    Location
    Stockport, England
    MS-Off Ver
    2007
    Posts
    91

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    Hi Doc.AElstein, thanks for the tip. This works much better for the time being.

    Thanks so much for the help!! Have a great 2018. Hope to speak to you again.

    Regards
    Mark

  7. #7
    Registered User
    Join Date
    03-07-2017
    Location
    Stockport, England
    MS-Off Ver
    2007
    Posts
    91

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    Thanks also to everyone else. I will give the SpecialCells option a go as well, thanks Norie.

  8. #8
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Current code searches entire worksheet, need to search just A column of multiple workb

    Thanks Mark for the feedback and Rep thingy, ( and for marking the Thread as Solved )
    Dave Alan
    Last edited by Doc.AElstein; 01-02-2018 at 03:00 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How can I use below code for ONLY Particular Column, NOT entire worksheet
    By rajeshn_in in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2016, 09:01 PM
  2. [SOLVED] Macro searches entire row, want to restric search to a smaller range
    By Butcher1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2015, 11:44 AM
  3. [SOLVED] Search multiple worksheets for Text String, copy and paste entire row into new worksheet
    By spulliam2000 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-15-2013, 07:52 PM
  4. [SOLVED] Macro to Search column for Text string and Copy Entire Row to another Worksheet
    By TJacks1908 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2013, 07:11 AM
  5. [SOLVED] search multiple worksheets in workbook for keyword then copy entire row to new worksheet
    By sck22 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-25-2012, 02:22 AM
  6. [SOLVED] Macro that searches a column for all the blank cells then highlights the row entire row.
    By TheOllie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2012, 09:41 AM
  7. Search Field that searches multiple workbooks
    By justjon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2009, 09:10 AM

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