+ Reply to Thread
Results 1 to 11 of 11

VB Code to pull data from Sheet1 and paste in Sheet2

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to pull data from Sheet1 and paste in Sheet2

    Hello:

    Please refer to attached file.

    I have Employee Time Record as shown in attached file Sheet1 of 05-24-2017-TimeSheet.

    I need VB Code to pull total hours worked for each employee from sheet and paste in Sheet2 as shown.

    The data in Sheet1 will be consistently same as shown.

    My logic is to first look for names of the employee in column A (to get the names of employees exclude all name staring with Mon,Tue,Wed,Thu,Fri,Sat,Sun.
    Total Hours worked is always in Column G.

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,749

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    The way these sheets are formatted makes everything more difficult. The skinny blank rows are not consistent (sometimes one, sometimes two, sometimes none) and make either formulas or VBA harder.

    How tied are you to this formatting? Your problem can be solved with straightforward formulas, no code, with a little reformatting.

    Also you have hard values for Total Time when it could be calculated. It's a little unclear what the big picture it, but see attached for my recommendation. The file was in Excel 97-2002 format but the formula uses newer functions so I have saved it as .xslx. Your profile shows you have 2010 so that shouldn't be a problem.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Hello:

    Thanks a lot with the formula approach, however doing reformatting correctly every time will be prone to error.

    i was thinking of VB to delete all blank rows and come up with the data as shown in attached pic.

    Please let me know if you have any questions.
    Thanks.

    Riz

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Attached pic
    Attached Images Attached Images

  5. #5
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Maybe :
    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Hello kareDog:

    Nothing happens with the code, please refer to attached file.
    i have put your above code.

    Please let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files
    Last edited by rizmomin; 05-25-2017 at 04:47 AM.

  7. #7
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Hi Riz,

    For the file attached in post #1, you need to clear contents of Sheet2!A13:G17 first, the macro will put the output to this range.

    For the file attached in post #6, the output is put on "Sheet4", because you rename Sheet2("Sheet2") to "Sheet4".
    If you want the output is put on Sheet3("Sheet2"), you need change the code to :
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Hi Karedog:

    It works in file in POst#1.
    However, attatched is the actual file with no Sheet2.
    I created Sheet2 manually and tried teh code but did not work.
    Please help modify the code for the attached file.
    Once again thank you so much for great help.

    Riz
    Attached Files Attached Files

  9. #9
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Riz,

    It is not because you create Sheet2 manually, but because for the file on post #8, you have merged cells for A13:Q13, A43:Q43, etc (which is not the case for previous files).
    Please try this code :

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    Hi Karedog:

    Seems to work...i will try further and let you know if any issues.
    Thanks a lot..Great Help.

    Riz

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VB Code to pull data from Sheet1 and paste in Sheet2

    You are welcome Riz, thanks for the reps.

    Regards

+ 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] VBA Code: Copy paste from sheet1 to next avaiable row in sheet2
    By leigh12483 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-31-2015, 07:31 PM
  2. [SOLVED] I need code to pull radio option selection on sheet1 to sheet2
    By TAMMY32 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-07-2014, 11:46 PM
  3. Pull Data From Sheet2 Into Grid On Sheet1
    By jo15765 in forum Excel General
    Replies: 2
    Last Post: 06-10-2014, 04:19 PM
  4. Replies: 6
    Last Post: 07-25-2013, 02:58 PM
  5. Macro to pull data from sheet1 to sheet2
    By rupss01 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-11-2011, 02:29 AM
  6. Replies: 15
    Last Post: 01-19-2011, 11:37 PM
  7. Pull data from sheet2 to sheet1 help
    By lilc420 in forum Excel General
    Replies: 3
    Last Post: 08-23-2010, 12:34 AM

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