VBS cutting and Pasting data to each new sheet generated

yldiver

New Member
Joined
Nov 8, 2007
Messages
1
Hi. I'm new to VBA and I'm trying to code some things to auto populate new sheets. I have this code below that works great. It takes each line of a range and adds a new sheet naming it from each row in the range. However, on each new sheet I also need it to copy and paste data from another range (D3:D(length dependant on lines of nonblank data)) and paste each new line to cell (L1) of the current newly made sheet. It also has to have a hard return so that other formulas on the new sheet recognize that data is in L1. Like the below code this would loop until it reaches the first blank row. Thanks!

Sub Copy_Sheets()
Dim Rng As Range, cell As Range
Dim LR As Long

LR = Sheets("Diver Data").Range("D" & Rows.Count).End(xlUp).Row
Set Rng = Sheets("Diver Data").Range("F3:F" & LR)

For Each cell In Rng
If Not Evaluate("ISREF('" & cell & "'!F3)") Then
Sheets("Blank IHSA Sheet").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = cell
End If
Next

End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,222,143
Messages
6,164,174
Members
451,880
Latest member
2da

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