?
Solved

Excel Macro - question and assistance

Posted on 2015-01-19
5
Medium Priority
?
65 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
[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 Comments
 
LVL 46

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

764 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