Solved

Excel Macro - question and assistance

Posted on 2015-01-19
5
57 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:SimonAdept
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 5

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 5

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 31

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now