Solved

Excel Macro - question and assistance

Posted on 2015-01-19
5
63 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 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
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…

707 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