Solved

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

Posted on 2011-03-22
7
1,064 Views
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
0
Comment
Question by:decisionfocus
  • 4
  • 3
7 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35186960
Format Sheet Missing.

Sid
0
 

Author Comment

by:decisionfocus
ID: 35186965
Hi Sid,

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

Br Jonas
Solar-Weekly-0.2.xls
0
 
LVL 30

Expert Comment

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

Just cleaning it and testing it :)

Sid
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 30

Accepted Solution

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

Sid

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.Range("A36:X36")
        ws2.Rows("35:36").EntireRow.Hidden = True
    Next i
    
LetsContinue:
    Sheets("Format").Visible = False
    Application.ScreenUpdating = True
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume LetsContinue
End Sub

Open in new window

Solar-Weekly-0.1.xls
0
 

Author Comment

by:decisionfocus
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..
0
 

Author Closing Comment

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

Expert Comment

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

Sure not a problem :)

Sid
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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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.

744 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

13 Experts available now in Live!

Get 1:1 Help Now