Solved

Split data over rows in excel

Posted on 2011-09-09
8
287 Views
Last Modified: 2012-05-12
Guys I think this should be straight forward but I need some assistance.
I have a list of information that spans from column A2 to column H500 but it would vary. This information needs to be copied into another sheet but needs to have 8 rows separating each of the rows of data this is so that the list fits into a formatted sheet.

I have attached an example

Can anyone help

Regards

Darren
EE-Sample.xls
0
Comment
Question by:DarrenJackson
  • 5
  • 3
8 Comments
 
LVL 19

Expert Comment

by:akoster
ID: 36509221
So in effect you want to transform

row1
row2
row3
[...]

to

row1
empty_row_1
empty_row_2
empty_row_3
empty_row_4
empty_row_5
empty_row_6
empty_row_7
empty_row_8
row2
empty_row_1
empty_row_2
empty_row_3
empty_row_4
empty_row_5
empty_row_6
empty_row_7
empty_row_8
row3
empty_row_1
empty_row_2
empty_row_3
empty_row_4
empty_row_5
empty_row_6
empty_row_7
empty_row_8
[...]
0
 
LVL 19

Expert Comment

by:akoster
ID: 36509260
this can be done by running a macro such as

Sub perform_copy()

    target_sheet = "Sheet2"
    target_row = 1
    For Each Row In UsedRange.Rows
        Row.copy Worksheets(target_sheet).Cells(target_row, 1)
        target_row = target_row + 8
    Next Row

End Sub

Open in new window

0
 

Author Comment

by:DarrenJackson
ID: 36510052
akoster

thanks for replying but the code when pasted into the sample sheet I attached doesnt seem to work.

I assume it need to be pasted into the VB Sheet1 object but it errors after copying 1 line

Regards
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 19

Expert Comment

by:akoster
ID: 36510632
DarrenJackson,

that would be because of :

 - the sheet "Sheet2" does not exist
 - there should be an offset : firstname is located in column A in list and column B in new sheet.

I'm sorry i did not use your sheet, this would be the better solution:
Sub perform_copy()

    target_sheet = "New Sheet"
    target_row = 28
    target_column = 2
    For Each Row In UsedRange.Rows
        If Row.Row > 1 Then
            '-- copy data rows but skip first row (header)
            Row.Copy Worksheets(target_sheet).Cells(target_row, target_column)
            target_row = target_row + 8
        End If
    Next Row

End Sub

Open in new window


EE-Sample.xls
0
 

Author Comment

by:DarrenJackson
ID: 36510789
Akoster thanks again. Im seeing ti working but my formatting is looking to be causing issues with the way the info is copied over I am unable to copy the data to rows 4..12 etc  in the new sheet.

Any Ideas

Cheers
0
 
LVL 19

Accepted Solution

by:
akoster earned 500 total points
ID: 36510840
I guess this is caused by the use of combined cells. This will work :
Sub perform_copy()

    target_sheet = "New Sheet"
    target_row = 4
    target_column_offset = 1
    For Each Row In UsedRange.Rows
        If Row.Row > 1 Then
            '-- copy data rows but skip first row (header)
            For col = 1 To 8
                Worksheets(target_sheet).Cells(target_row, target_column_offset + col) = Row.Cells(col)
            Next col
            target_row = target_row + 8
        End If
    Next Row

End Sub

Open in new window

0
 

Author Comment

by:DarrenJackson
ID: 36510919
Akoster perfect

This is excatly what I need thanks

Regards

Darren
0
 
LVL 19

Expert Comment

by:akoster
ID: 36511244
you're welcome !
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove duplicates using cell values VBA 2 32
VLOOKUP 6 17
If help 9 48
Excel - remove duplicates 1 13
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question