Solved

Excel Macro - question and assistance

Posted on 2015-01-19
5
62 Views
Last Modified: 2015-02-03
I have a database export that contains about 350 records. (WTC1)  My goal is to write a macro that will parse the data in each of the rows into a separate sheet, which they would have the data set out as it's displayed in the document called "Survey List"

First is it possible to use the marco function to separate 350 rows into 350 worksheets?

If yes, I will need post a follow up question with details. Thank you
Copy-of-WTC-Survey-Field-List---140801.x
WTC1.xlsx
0
Comment
Question by:mcpilot1
5 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 40558476
Your posted files don't indicate how the data is to be distributed.
0
 
LVL 18

Expert Comment

by:Simon
ID: 40558486
Yes, easily possible to generate a worksheet for each line. Do you want all worksheets in the same workbook?

I believe the maximum number of worksheets is only limited by the available RAM.
0
 
LVL 6

Accepted Solution

by:
Flora earned 500 total points
ID: 40558967
here is the code ready for ya

Option Explicit

Sub SplitDataNrows()
'Jerry Beaucaire,  2/28/2012
'Split a data sheet by a variable number or rows per sheet, optional titles
Dim N As Long, rw As Long, LR As Long, Titles As Boolean

    If MsgBox("Split the activesheet into smaller sheets?", vbYesNo, _
                "Confirm") = vbNo Then Exit Sub
    N = Application.InputBox("How many rows per sheet?", "N-Rows", 50, Type:=1)
    If N = 0 Then Exit Sub
    If MsgBox("Include the title row1 on each new sheet?", vbYesNo, _
                "Titles?") = vbYes Then Titles = True

    Application.ScreenUpdating = False
    With ActiveSheet
        LR = .Range("A" & .Rows.Count).End(xlUp).Row
        
        For rw = 1 + ---Titles To LR Step N
            Sheets.Add
            If Titles Then
                .Rows(1).Copy Range("A1")
                .Range("A" & rw).Resize(N).EntireRow.Copy Range("A2")
            Else
                .Range("A" & rw).Resize(N).EntireRow.Copy Range("A1")
            End If
            Columns.AutoFit
        Next rw
        
        .Activate
    End With
    Application.ScreenUpdating = True

End Sub

Open in new window

0
 
LVL 6

Expert Comment

by:Flora
ID: 40558968
once you run this code, it will prompt for inputbox and then type 1 and then it will ask if you want to include header row, it is up to you, you could click yes or no and then you will see all separate sheets for each of your rows.
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40559653
Do you actually need 350 separate sheets?

Could you work with a Report sheet that is formula driven based on an ID (or just row number) input into one column and then the other columns pull data from the source sheet based on that ID?

Thanks
Rob H
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

696 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