Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How to insert new worksheet based on # of rows in a data sourch

Hello,

I am trying to get the below VBA code to only copy "form" and create
new worksheet based on number of rows with data in my "data" sheet.
Is there a way that can be done?

Sub Copy_Sheets()

Dim i As Integer
Dim wks As Worksheet

For i = 1 To 45

Sheets("form").Copy After:=Sheets(2)
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default How to insert new worksheet based on # of rows in a data sourch

On Wednesday, May 2, 2012 10:09:21 AM UTC-5, Rachel Rios wrote:
Hello,

I am trying to get the below VBA code to only copy "form" and create
new worksheet based on number of rows with data in my "data" sheet.
Is there a way that can be done?

Sub Copy_Sheets()

Dim i As Integer
Dim wks As Worksheet

For i = 1 To 45

Sheets("form").Copy After:=Sheets(2)
Next

End Sub


more detail
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 621
Default How to insert new worksheet based on # of rows in a data sourch

Assuming Column A has range of rows to count.

Sub Copy_Sheets()
Dim i As Integer
Dim rng1 As Integer
rng1 = Sheets("Data").Cells(Rows.Count, 1).End(xlUp).Row
MsgBox rng1 & " Sheets will be added"
For i = rng1 To 1 Step -1
Sheets("form").Copy after:=Sheets(2)
ActiveSheet.Name = "form" & i
Next
End Sub


Gord

On Wed, 2 May 2012 08:09:21 -0700 (PDT), Rachel Rios
wrote:

Hello,

I am trying to get the below VBA code to only copy "form" and create
new worksheet based on number of rows with data in my "data" sheet.
Is there a way that can be done?

Sub Copy_Sheets()

Dim i As Integer
Dim wks As Worksheet

For i = 1 To 45

Sheets("form").Copy After:=Sheets(2)
Next

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert rows based on value per day Mayte Excel Worksheet Functions 2 May 2nd 08 03:03 PM
How to insert rows based on change in data Leoc Excel Worksheet Functions 2 January 23rd 08 10:12 PM
Insert new rows based on Data in other rows mg_sv_r Excel Worksheet Functions 5 November 21st 07 01:51 PM
Insert Rows Based on values in another worksheet Jason Excel Discussion (Misc queries) 3 June 24th 07 01:13 PM
Excel Data Sourch Setup for Merge Dvinechild Setting up and Configuration of Excel 0 April 4th 07 09:06 PM


All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"