Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default If I insert a row in my worksheet, I have to change the row manua

Hello I was wondering if there is a way around this problem.
I have the following code.

Public Sub daily2()

Dim rng As Range, rng2 As Range
Dim sh As Worksheet, sh1 As Worksheet
Dim wsheetname As String
Dim res As Variant
Dim DT As Date, s As String
Dim sname As String
Worksheets("planning").Select
Range("A1").Select
I = 10
For g = 1 To 4
For f = 1 To 5
s = Worksheets("planning").Cells(2, 10).Value

Range("d2:h75").Copy

Worksheets.Add After:=Worksheets(Worksheets.Count)
Set sh1 = ActiveSheet




sh1.Select
ActiveCell.Offset(0, 0).Range("A1").Select
ActiveSheet.Paste Link:=True
Application.CutCopyMode = False
ActiveWindow.DisplayZeros = False

Worksheets("planning").Select

Range(Cells(2, I), Cells(75, I + 1)).Select

Selection.Copy
sh1.Select


ActiveCell.Offset(0, 5).Range("A1").Select
ActiveSheet.Paste Link:=True

sname = Range("f1").Value
sh1.Name = FORMAT(sname, "ddd") & g

L = L + 1
I = I + 2
Next f
I = I + 4
Next g
Range("1:1").Select
End Sub

if I add a row in worksheets("planning"), I would then have to manually
change

Range("d2:h75").Copy
Range(Cells(2, I), Cells(75, I + 1)).Select

I need to paste as a link

also If I add a row in worksheet("planning") I want the new sheet to
automatically add a row. Is this possible?

thanks in advance

Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default If I insert a row in my worksheet, I have to change the row manua

try using lastrow instead of 75. change column from "a" to yours
lastrow=cells(rows.count,"a").end(xlup).row

--
Don Guillett
SalesAid Software

"Paul" wrote in message
...
Hello I was wondering if there is a way around this problem.
I have the following code.

Public Sub daily2()

Dim rng As Range, rng2 As Range
Dim sh As Worksheet, sh1 As Worksheet
Dim wsheetname As String
Dim res As Variant
Dim DT As Date, s As String
Dim sname As String
Worksheets("planning").Select
Range("A1").Select
I = 10
For g = 1 To 4
For f = 1 To 5
s = Worksheets("planning").Cells(2, 10).Value

Range("d2:h75").Copy

Worksheets.Add After:=Worksheets(Worksheets.Count)
Set sh1 = ActiveSheet




sh1.Select
ActiveCell.Offset(0, 0).Range("A1").Select
ActiveSheet.Paste Link:=True
Application.CutCopyMode = False
ActiveWindow.DisplayZeros = False

Worksheets("planning").Select

Range(Cells(2, I), Cells(75, I + 1)).Select

Selection.Copy
sh1.Select


ActiveCell.Offset(0, 5).Range("A1").Select
ActiveSheet.Paste Link:=True

sname = Range("f1").Value
sh1.Name = FORMAT(sname, "ddd") & g

L = L + 1
I = I + 2
Next f
I = I + 4
Next g
Range("1:1").Select
End Sub

if I add a row in worksheets("planning"), I would then have to manually
change

Range("d2:h75").Copy
Range(Cells(2, I), Cells(75, I + 1)).Select

I need to paste as a link

also If I add a row in worksheet("planning") I want the new sheet to
automatically add a row. Is this possible?

thanks in advance

Paul



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
Cannot insert worksheet in exel - not available in insert menu pedro39 Excel Worksheet Functions 1 July 24th 08 12:09 PM
insert rows in a worksheet that do not change adjoining rows craigandmel Excel Discussion (Misc queries) 2 April 29th 08 10:26 PM
Formula not populating from dropdown box.Works when entered manua Grandmother of 2 Excel Worksheet Functions 2 January 1st 07 03:46 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM


All times are GMT +1. The time now is 05:08 PM.

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"