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


Excel 2007/2010: traverse data range, create new sheet per row, copy current row into new sheet

Posted on 2011-03-22
Medium Priority
Last Modified: 2012-05-11
Hi - got a problem i hope you'd be able to help me solve.

I have  workbook (attached here) with two sheets, "Data Input" & "Format" - "Format" is a hidden sheet. In the "Data Input" sheet I have 1 header row (row 1) and X data rows (rows 2-X). I need to for each data-row:

- Create a copy of the "Format" sheet
- Copy the current data row from "Data Input" into the newly created copy of "Format" in A36:X36
- set the name of the newly created sheet to the value in cell B36
- Hide range A35:X36 in the newly created sheet

When done for all data-rows i need to

- Hide the "Data Input" sheet

Any help would be greatly appreciated!

Br Jonas Solar-Weekly-0.1.xls
Question by:decisionfocus
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
  • 4
  • 3
LVL 30

Expert Comment

ID: 35186960
Format Sheet Missing.


Author Comment

ID: 35186965
Hi Sid,

Sorry - have attached new file. The format sheet is hidden but unprotected.

Br Jonas
LVL 30

Expert Comment

ID: 35186969
The code is almost ready... :)

Just cleaning it and testing it :)

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!

LVL 30

Accepted Solution

SiddharthRout earned 2000 total points
ID: 35187006
Ok here is the file. Please run the macro Sample in Module 1.


Code Used

Sub Sample()
    Dim i As Long, LastRow As Long
    Dim ws1 As Worksheet, ws2 As Worksheet
    On Error GoTo Whoa
    Application.ScreenUpdating = False
    Set ws1 = Sheets("Data Input")
    LastRow = ws1.Range("A" & Rows.Count).End(xlUp).Row
    Sheets("Format").Visible = True
    For i = 2 To LastRow
        Sheets("Format").Copy After:=Sheets(Sheets.Count)
        Set ws2 = ActiveSheet
        ws2.Name = ws1.Range("B" & i).Value
        ws1.Range("A" & i & ":X" & i).Copy _
        ws2.Rows("35:36").EntireRow.Hidden = True
    Next i
    Sheets("Format").Visible = False
    Application.ScreenUpdating = True
    Exit Sub
    MsgBox Err.Description
    Resume LetsContinue
End Sub

Open in new window


Author Comment

ID: 35187071
That is absolutely AMAZING - thanks so much for your help! I actually have another question, but i prefer to create it as a new question so i can give more points for it - hope you'll be able to take a quick look at it as well..

Author Closing Comment

ID: 35187075
Amazingly quick & correc answer - best help imaginable!
LVL 30

Expert Comment

ID: 35187124
>>>hope you'll be able to take a quick look at it as well..

Sure not a problem :)


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

618 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