Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Split data over rows in excel

Posted on 2011-09-09
8
Medium Priority
?
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 19

Expert Comment

by:Arno Koster
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:Arno Koster
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 19

Expert Comment

by:Arno Koster
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:
Arno Koster earned 2000 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:Arno Koster
ID: 36511244
you're welcome !
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

604 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