VBA to create and prepopulate worksheets

epasra

New Member
Joined
Aug 4, 2011
Messages
2
I have a workbook with one worksheet that contains about 200 records. I would like to create a macro that creates a separate worksheet for each individual record, name the worksheet by the value in the A column, and insert the data in columns B-E in the first row of each new worksheet.

Any ideas how to do this? Any help will be greatly appreciated!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I would really appreciate any help you can throw my way.

Again, I have 200 records of data. I would like to automate the process of creating a new worksheet for each record, naming the worksheet the value in the A column, and inserting the value of the cells in B and beyond in the first row of each sheet.
 
Upvote 0
This assumes the detail is in sheet1 - Name in A and the copied range is B to E of the row
Pasted in B1 of the added sheet.
Code:
Sub AddRecords()
Dim Rng As Range
Dim Dn As Range
Sheets("Sheet1").Activate
Set Rng = Sheets("Sheet1").Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
 
For Each Dn In Rng
Sheets("Sheet1").Activate
RowNum = Dn.Row
Range("B" & RowNum & ":E" & RowNum).Copy
Sheets.Add.Name = Dn.value
ActiveSheet.Range("B1").PasteSpecial
 
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,538
Messages
6,179,412
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top