+ Reply to Thread
Results 1 to 6 of 6

VB Code or formula to rearrange data

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

    VB Code or formula to rearrange data

    Hello:

    Please refer to attached file.

    I have data as shown in Sheet1, Column C is employee name.
    The data are schedule for employee, Column D and E for MON, Column F and G for TUE, Column H & I for WED and so on until SUNDAY.
    I need formula or VB approch to put the data for related employee in Sheet2 in column D,F,H,J,L,N and p for MON-SUN as shown.
    I have manually done so for MON.

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files
    Last edited by rizmomin; 12-31-2016 at 09:38 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: VB Code or formula to rearrange data

    Hi Riz,

    Happy New Year to you.

    You can put this formula in cell D4 of Sheet2:

    =IFERROR(IF(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0)="","",IF(ISNUMBER(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0)),TEXT(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0),"h:mm")&" to "&TEXT(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:E),0),"h:mm"),VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0))),"")

    then copy it down into D5:D60. Then copy the block of cells from D4:D60 across into the other columns, at F4, H4, J4 and so on (i.e. the other yellow columns).

    Hope this helps.

    Pete

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

    Re: VB Code or formula to rearrange data

    Hello Pete_UK:

    Seems to work with small glitch.
    Please refer to attached file.
    2nd part of the data for the day is not correct.
    Example :

    Sheet2 : Cell D6 shows 15:00 to 15:00 and this needs to be 15:00 to 17:00


    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code or formula to rearrange data

    Hi Riz,

    Happy New Year to you.

    I assumed that you may want to work with the Hours of each Shift, which required me to change your Workbook layout a bit, and gave you, what I believe you will approve.

    Please see attachment.

    Kind Regards.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: VB Code or formula to rearrange data

    Hello Riz,

    this is the formula that you have in D4:

    =IFERROR(IF(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0)="","",IF(ISNUMBER(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0)),TEXT(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0),"h:mm")&" to "&TEXT(VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0),"h:mm"),VLOOKUP($C4,Sheet1!$C:$Q,COLUMNS($C:D),0))),"")

    Note that the D which is shown in red should be E.

    I've attached the file that I worked on this morning to show this.

    Hope this helps.

    Pete
    Attached Files Attached Files

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

    Re: VB Code or formula to rearrange data

    Hello Pete and Winon:

    Solution works great, totally forgot.
    Winon, you knew what i was getting at.
    Thanks a lot
    Riz

+ 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] VB Code to rearrange the data
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-29-2016, 06:12 AM
  2. VBA code to collect and rearrange data coming from pivot table
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2016, 02:56 AM
  3. Replies: 0
    Last Post: 03-03-2015, 06:20 PM
  4. [SOLVED] Rearrange Data with formula
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-13-2014, 09:19 AM
  5. [SOLVED] VBA code to rearrange data into multiple columns
    By shinobi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2013, 06:33 AM
  6. Formula to remove unwanted data & rearrange last name & first name in a cell
    By rbecker69 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 03:12 AM
  7. [SOLVED] Getting Error 1004 Object or Application Defined Error - Code to rearrange data
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-10-2013, 12:10 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