+ Reply to Thread
Results 1 to 4 of 4

I need to reorganize the data with VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1

    I need to reorganize the data with VBA

    I have data organized in a file. I want to basically have the data reorganized into a specific format/order and continue to the bottom of the list. It might be a copy/paste thing?

    I need the VBA for this. I've attached an example. Thanks for the help!
    Attached Files Attached Files
    Last edited by baetienne; 05-29-2014 at 03:14 PM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: I need to reorganize the data with VBA

    I am sure this is not your real data. The output is in new sheet.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: I need to reorganize the data with VBA

    Does this help?

    Sub baetienne()
    Dim i As Long
    For i = 6 To 9
        Range(Cells(5, "E"), Cells(5, "I")).Copy
        Sheets("Sheet2").Range("B" & Rows.count).End(3)(2).PasteSpecial Transpose:=True
        Range(Cells(i, "E"), Cells(i, "I")).Copy
        Sheets("Sheet2").Range("C" & Rows.count).End(3)(2).PasteSpecial Transpose:=True
        Sheets("Sheet2").Range("A" & Rows.count).End(3)(2).Resize(5).Value = Range("D" & i).Value
    Next i
    End Sub
    Sends the results to Sheet2 based on your sample data.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,903

    Re: I need to reorganize the data with VBA

    Try this:

    Option Explicit
    
    Sub foo()
    Dim ws As Worksheet
    Set ws = Sheets("Sheet1")
    Dim sh As Worksheet
    Set sh = Sheets("Sheet2")
    Dim rng As Range
    Set rng = ws.Range("E5:I5")
    Dim lr As Long
    lr = ws.Range("D" & Rows.Count).End(xlUp).Row
    Dim lr2 As Long
    Dim i As Long
    
    For i = 6 To lr
    lr2 = sh.Range("B" & Rows.Count).End(xlUp).Row
    With ws
        .Range("D" & i).Copy sh.Range("A" & lr2 + 1)
        rng.Copy
        sh.Range("B" & lr2 + 1).PasteSpecial xlPasteAll, , , True
        .Range("E" & i & ":I" & i).Copy
        sh.Range("C" & lr2 + 1).PasteSpecial xlPasteAll, , , True
        
    End With
    Next i
    Application.CutCopyMode = False
    
    End Sub
    Create a second sheet called Sheet2; put these headings on the sheet
    A1 = Project, B1 = Group, C1= Amount

    Then run the code.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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. Reorganize data
    By Kayline in forum Excel General
    Replies: 6
    Last Post: 03-06-2013, 11:57 AM
  2. Reorganize data
    By ngpm515 in forum Excel General
    Replies: 0
    Last Post: 11-02-2011, 05:19 PM
  3. Reorganize a data set
    By RPADC in forum Excel General
    Replies: 3
    Last Post: 07-11-2010, 02:19 PM
  4. Reorganize data
    By pentiumeric in forum Excel General
    Replies: 13
    Last Post: 07-13-2009, 04:32 AM

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