+ Reply to Thread
Results 1 to 7 of 7

Pull data from one sheet to another based on cell value

  1. #1
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    107

    Pull data from one sheet to another based on cell value

    I AM TRYING TO CREATE VBA CODE TO PULL ALL DATA FROM SHEET 'NB' TO SHEET 'NBD' IF
    CONDITION 1 ) VALUE GIVEN IN B2 TO B1OO IN 'AG-MNU' SHEET MATCHES WITH DATA IN
    COL J1 TO J100 OF 'NB' SHEET AND
    CONDITION 2) DATE RANGE GIVEN BETWEEN T3 TO T5 OF 'AG-MNU' SHEET MATCHES WITH COL.
    C2 TO C100 OF 'NB' SHEET'.
    BELOW MENTIONED VBA CODE IS PULLING ALL DATA PROM SHEET NB TO SHEET NBD. PROVIDE SOLUTION

    Sub PULLDATA()
    With Sheets("NBD")
    .Cells.Clear
    Sheets("NB").Cells(1).CurrentRegion.AdvancedFilter xlFilterCopy, Sheets("AG-MNU").Range("B2:B100"), .Cells(1)
    End With
    End Sub
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    727

    Re: Pull data from one sheet to another based on cell value

    Maybe something like this ?
    Please Login or Register  to view this content.
    Last edited by karmapala; 06-17-2020 at 02:46 PM.

  3. #3
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    107

    Re: Pull data from one sheet to another based on cell value

    Your code is not working at all. Not a single record is shown in 'nbd' sheet. Your are requested to try the code on sample file and post reply.

  4. #4
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    727

    Re: Pull data from one sheet to another based on cell value

    Quote Originally Posted by kv.singh View Post
    Your code is not working at all.
    Not a single record is shown in 'nbd' sheet.

    If you try the code in your sample workbook without any changes in your sample workbook,
    it won't give you any result in sheet NBD, since there are no date in between 20200401 and 20200430 in column C of sheet NB.

    DATE RANGE GIVEN BETWEEN T3 TO T5 OF 'AG-MNU' SHEET MATCHES WITH COL.
    C2 TO C100 OF 'NB' SHEET'
    The from date - to date in your sample workbook sheet AG-MNU is : 20200401 TO 20200430.

    I assume that the 20200401 is 1 April 2020
    and the 20200430 is 30 April 2020.

    There are year 2020 in column C of sheet NB :
    20200115 ---> 15 Jan 2020
    20200115 ---> 15 Jan 2020
    20200128 ---> 28 Jan 2020
    20200214 ---> 14 Feb 2020

    Again, if you don't do any changes to your sample workbook,
    so the from date - to date is still 20200401 TO 20200430 in sheet AG-MNU,
    the code will still not give you a result in sheet NBD,
    because 15Jan2020, 28Jan2020, 14Feb2020 is not in between 1Apr2020 and 30Apr2020.

    So think I was mistaken to understand what you mean,
    because it seems that you still want to get a result in sheet NBD,
    then it seems that my reason (on why there is no result in NBD) in green is wrong

    Anyway, if you change the from date - to date in sheet AG-MNU like this ---> 20190828 to 20200430,
    then the code should give you a result in sheet NBD.

  5. #5
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    107

    Re: Pull data from one sheet to another based on cell value

    Sorry sir, it was my mistake. Your code is giving expected result. Kindly suggest one change .when i run code again after changing data old data of "nbd" should clear first. Currently code is appending data
    i want to overwrite data.

  6. #6
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    727

    Re: Pull data from one sheet to another based on cell value

    Quote Originally Posted by kv.singh View Post
    when i run code again after changing data old data of "nbd" should clear first
    Try to put this line :
    Please Login or Register  to view this content.
    right after this line:
    Please Login or Register  to view this content.
    Anyway, I've edited the code post #2 based on your request in this post.

  7. #7
    Forum Contributor
    Join Date
    10-30-2019
    Location
    GUJARAT,INDIA
    MS-Off Ver
    MS OFFICE 2016
    Posts
    107

    Re: Pull data from one sheet to another based on cell value

    Thanks for your guidance.my problem is solved

+ 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. need vba to pull data from another sheet based on cell input
    By anuwers in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-29-2020, 02:03 PM
  2. Replies: 0
    Last Post: 03-30-2016, 09:08 PM
  3. Formula to pull data from one sheet to a new sheet based on date range
    By lisajolley11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-15-2015, 08:38 PM
  4. Pull data from multiple sheets based on cell in Main sheet
    By cpyter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-29-2014, 01:19 PM
  5. [SOLVED] VBA to pull data from worksheet to a new sheet based on specific text cell value
    By TalResha in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-13-2013, 02:11 AM
  6. Replies: 19
    Last Post: 05-13-2013, 01:08 PM
  7. Replies: 3
    Last Post: 01-27-2013, 07:23 PM

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