+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    02-16-2010
    Location
    Nigeria
    MS-Off Ver
    Excel 2003
    Posts
    5

    Automatically insert row & Transpose

    Hello everybody,

    I'm new to this forum and I hope somebody can help me with my spreadsheet.

    I will pls. need a macro that will automatically insert rows and copy the same information but at the same time insert new columns (Column S to V) to transpose the hours in each day. Pls. separate each person with a straight line after grouping them. (I did 5 names as an example of what I need)

    Attach is the spreadsheet for reference.

    Appreciate any help. Thanks!
    Attached Files Attached Files
    Last edited by nelly4soti; 03-13-2010 at 06:00 AM.

  2. #2
    Registered User
    Join Date
    02-16-2010
    Location
    Nigeria
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Automatically insert row & Transpose

    Hi!

    Pls. is there anybody that could help me?

  3. #3
    Registered User
    Join Date
    02-16-2010
    Location
    Nigeria
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Automatically insert row & Transpose

    Hi everybody!
    could somebody pls help me because i really need a solution to this file to enable me submit my report .

  4. #4
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,228

    Re: Automatically insert row & Transpose

    Try this:
    Code:
    Option Explicit
    
    Sub ReformatData()
    'JBeaucaire   3/12/2010
    Dim LR As Long, Rw As Long, i As Long
    Dim DateArr As Variant
    Application.ScreenUpdating = False
    
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
    Columns("S:V").Insert xlShiftToRight
    Range("S1:V1").Value = [{"Year","Month","Day","Hours"}]
    
        For i = 23 To 29
            Range("BA" & i - 22, "BC" & i - 22) = Split(Cells(1, i), "_")
        Next i
        Range("BB:BB").Cut Range("BD1")
        Range("BA:BA").Cut Range("BE1")
        DateArr = Range("BC1:BE7")
        Range("BC1:BE7").ClearContents
        
        For Rw = LR To 2 Step -1
            Rows(Rw).Copy
            Rows(Rw + 1 & ":" & Rw + 6).Insert xlShiftDown
            Range("S" & Rw).Resize(7, 3) = DateArr
            Range("W" & Rw, "AC" & Rw).Copy
            Range("V" & Rw).PasteSpecial xlPasteValues, Transpose:=True
        Next Rw
    
    Columns("W:AC").ClearContents
    Columns.AutoFit
    Application.ScreenUpdating = True
    End Sub

    How/Where to install the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    02-16-2010
    Location
    Nigeria
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Automatically insert row & Transpose

    Hi Jerry I'm so happy for the formula you gave to me. it works very well!!!

    Thank you!!!!!

    Ciao

Thread Information

Users Browsing this Thread

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

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.2.0