+ Reply to Thread
Results 1 to 26 of 26

To find Row with certain value and to check if range "M" of that Row has certain value.

  1. #1
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    To find Row with certain value and to check if range "M" of that Row has certain value.

    Hello everyone,

    I have Sub that loops through multiple files and the aim is to find row in range "B:B" (column B with Dates in descending order) with certain Date (date I'm looking for is recorded in range "W1" of Sheet1 in thisworkbook) and to check the value of range "M" of that row. If the value of the range "M" is "BUY" then I want to copy Range "A:O" of that row and Paste it to MasterSheet of thisworkbook, otherwise to close the file and proceed to the next one. I've figured out how to find cell with value, but I do not know how to incorporate "If" condition to check range "M" value of that row. I would be grateful for any help. Of course it does not have to be Find function if it is not the best way to solve problem, but one thing is important is that I need to be able to search date which is indicated in range "W1" and that value I want to be able to change manually whenever needed. Thank you in advance for your help.
    Dilshod

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Hi AlphaFrog,
    My apologies but the code is not working. I’m not sure why, may be Find portion of my code doesn’t do its job. I was wandering if you could have a look at the workbook and test file and figure out problem? Thank you in advance for your time.

    P.S. Failed to attach files as when I click "GoAdvanced" I'm not getting option "Manage Attachments".

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    What does "not working " exactly mean? Do you get an error? If yes, what is the error description and is a line of code highlighted when you Debug? Does it find a date match, but not copy the values?

    Do the dates in column B and the search-for date have the same date format?

    This is a guess, but give it a try...

    Set sDate = wb.Range("B:B").Find(what:=destwb.Worksheets("Sheet1").Range("B1").Formula, LookIn:=xlFormulass, LookAt:=xlWhole)

  5. #5
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    There is no error messages, it works smooth, that is why I thought that Find portion of the code is working, but when I've tried to run it with Copy/Paste part id did not copied/pasted searchable range.
    It does not find date.
    I've tried to change search arguments it did not help. Search-for date and Column B:B Dates formats look the same : 11/6/2020 14:30
    I've taken screenshots of both of the files but cannot attach them as attachment button does not work in my account.
    when I tried to change code to sDate.Activate or sDate.Select it does not selects cell with date value, I tried to change from xlWhole to xlPart, it did not change anything.
    Last edited by AliGW; 01-02-2021 at 09:11 AM. Reason: PLEASE don't quote unnecessarily!

  6. #6
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    When I try to debug, when the line Set sDate = wb.Range("B:B").Find(what:=destwb.Worksheets("Sheet1").Range("B1").Value, LookIn:=xlValues, lookat:=xlWhole) is highlighted and I hover cursor over sDate it gives sDate = Nothing.
    Last edited by AliGW; 01-02-2021 at 09:11 AM. Reason: PLEASE don't quote unnecessarily!

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

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    difficult without file upload...
    If you are making use of this from post 4 then remove red snippet...
    Please Login or Register  to view this content.
    Last edited by sintek; 01-02-2021 at 07:07 AM.
    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!!!

  8. #8
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Perhaps
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Quote Originally Posted by sintek View Post
    difficult without file upload...
    ...
    Thanks for your message.
    I do not know why "Attachments" button is not working in my case, I've tried several browsers with no result. I might have to look for help at another forum.
    Changing xlFormulass to xlFormulas did not change result.
    Last edited by AliGW; 01-02-2021 at 09:12 AM. Reason: PLEASE don't quote unnecessarily!

  10. #10
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Quote Originally Posted by mohadin View Post
    Perhaps
    Please Login or Register  to view this content.
    Thanks for your message.
    I've tried to change line to:
    Set sDate = wb.Worksheets(1).Range("B:B").Find(what:=destwb.Worksheets("Sheet1").Range("B1").Value, LookIn:=xlValues, lookat:=xlWhole)
    it did not help.
    name of the single sheet in each wb is the same as wb name.

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

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    dilshod_k...
    No need to quote entire posts...it just clutters the thread...
    To upload sample file...
    Just before posting, scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.
    Can go around in circles without it...You are looking for the text "Date"...should not be that complicated unless it does not exist in Column B
    Last edited by sintek; 01-02-2021 at 08:14 AM.

  12. #12
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Wink Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Hi sintek,
    when I click "Go Advanced" I do not get Tab or Button "Manage Attachments", I just get two tabs "Submit Reply" and "Preview Post", but I do get new button with paper clip ("Attachments") amidst text formatting options of the message. This button is not working on my page regardless of browser I'm using. I would record video of that and send it to you to prove but I'd still not be able to attach it.
    Last edited by dilshod_k; 01-02-2021 at 09:01 AM.

  13. #13
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    I think I found Manage attachments link. I've uploaded them and the only option remains is to close window. When I close it I do not see any files attached to message. Only when I press preview I can see them.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Wink Re: To find Row with certain value and to check if range "M" of that Row has certain value

    As for some reasons I was not able to attach files to my posts, I've cross published same question on another forum earlier today but I was not able to post link of that forum as my account apparently has restrictions on posting links.

  15. #15
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    "You are looking for the text "Date"...should not be that complicated unless it does not exist in Column B" -

    I'm not looking for text "Date". I'm looking for value in Date format (11/6/2020 14:30).

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,448

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    I've cross published same question on another forum earlier today but I was not able to post link of that forum as my account apparently has restrictions on posting links.
    You can post links now that you have posted here 10 times.

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  17. #17
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Thank you!
    The same query has been posted on:

    https://www.ozgrid.com/forum/index.p...y-paste-range/

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

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    This works for me...Change red snippet to your path...
    Please Login or Register  to view this content.

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,592

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    If the csv files are all identically structured then
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Hi sintek,

    Works perfectly well. Impressive. Thanks a lot. I would not be able to sort it out on my own. Appreciate it!

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,448

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

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

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Quote Originally Posted by dilshod_k View Post
    Hi sintek,

    Works perfectly well. Impressive. Thanks a lot. I would not be able to sort it out on my own. Appreciate it!
    Glad I could contribute...Tx for rep +

  23. #23
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Hi jindon-San,

    Thank you very much for your help! Even though "Open Folder" dialog box is not exactly what I wanted, as I need to loop through files with folder path indicated in the code, and I needed to check only one date, I'm still grateful for your post as you gave me an idea and ready made code to retrieve all dates from the history of the stock with "BUY" order.
    Arigatou gozaimashita

  24. #24
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,592

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Missed the Date in B1
    Please Login or Register  to view this content.

  25. #25
    Registered User
    Join Date
    01-01-2021
    Location
    Dublin, Ireland
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    "Missed the Date in B1"

    Hi Jindon-San,

    Your code works perfectly well AND it is the FASTEST CODE in terms of performance I had so far.
    Normally to loop through 800 csv files it would take me something between 167 to 210 sec.
    Your code does the same job in 151 sec. Thank you very much! Appreciate it.

    Dilshod

  26. #26
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,592

    Re: To find Row with certain value and to check if range "M" of that Row has certain value

    Glad you like it and thanks for the rep.

+ 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. Replies: 11
    Last Post: 06-05-2020, 02:08 AM
  2. [SOLVED] Check range and if 1 line has "Yes" all lines of the same get "Yes"
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-26-2018, 08:56 AM
  3. Replies: 2
    Last Post: 07-24-2017, 02:19 AM
  4. How do I do incorporate an "if statement" with the ".find" method in a range?
    By max3732 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2014, 08:14 PM
  5. Replies: 5
    Last Post: 01-23-2014, 11:02 AM
  6. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  7. [SOLVED] create links to check boxes marked "good" fair"and "bad"
    By pjb in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-19-2006, 09:25 PM

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