Copying a row of Cells in a Range

SimmonsDeux

New Member
Joined
Dec 29, 2014
Messages
17
Guys,
I have this code that works wonderfully for what I needed at one point:

Code:
Option Explicit

Sub AutoAddSheet()

Dim MyCell As Range, MyRange As Range

Set MyRange = Sheets("INDEX").Range("A1")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Sheets(2).Copy after:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = MyCell.Value
Next MyCell
End Sub

It copies everything in column A of my index sheet into a template sheet and repeats for every cell in column A.

My project has evolved and now I need it to copy a row of cells into specific cells on my template sheet. I need:

Col B from index to Cell B5 in Sheet2.
Col C from index to B9 in Sheet2.
Col D from Index to B8 in Sheet2.
Col E in Index to B7 in Sheet2.
Col F in Index to B3 in Sheet2.

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).
This should do what you are asking.

Code:
Option Explicit
Sub AutoAddSheet()
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("INDEX").Range("A1")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
For Each MyCell In MyRange
    Sheets(2).Copy after:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = MyCell.Value
    Sheets(Sheets.Count).Range("B5").Value = MyCell.Offset(0, 1).Value
    Sheets(Sheets.Count).Range("B9").Value = MyCell.Offset(0, 2).Value
    Sheets(Sheets.Count).Range("B8").Value = MyCell.Offset(0, 3).Value
    Sheets(Sheets.Count).Range("B7").Value = MyCell.Offset(0, 4).Value
    Sheets(Sheets.Count).Range("B3").Value = MyCell.Offset(0, 5).Value
Next MyCell
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,816
Members
449,469
Latest member
Kingwi11y

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