Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
LPS LPS is offline
external usenet poster
 
Posts: 108
Default Add New Row to Multiple Workbooks

Using Excel 2000, I have 8 workbooks, one sheet each, which all need the same
row added to the same place in each workbook, but it could be a different
location each time the rows are added (make sense?). For example, today I
may need to add a new row 5 to all 8 workbooks, but tomorrow I may ned to add
a new row 20 to all 8 workbooks. Is there a way to do this quickly, without
having to open each one and manually add the row in?

Any help is appreciated.
--
LPS

--
LPS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Add New Row to Multiple Workbooks

You can start with this code example
http://www.rondebruin.nl/copy4.htm
Post back if you need more help

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"LPS" wrote in message ...
Using Excel 2000, I have 8 workbooks, one sheet each, which all need the same
row added to the same place in each workbook, but it could be a different
location each time the rows are added (make sense?). For example, today I
may need to add a new row 5 to all 8 workbooks, but tomorrow I may ned to add
a new row 20 to all 8 workbooks. Is there a way to do this quickly, without
having to open each one and manually add the row in?

Any help is appreciated.
--
LPS

--
LPS

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Add New Row to Multiple Workbooks

Sub UpdateWorkbooks()
Dim sPath as String, v as Variant
Dim bk as Workbook, i as Long
Dim ans as Variant
rw as Long

ans = Application.Inputbox("Enter the row to add",type:=1)
if ans = false then exit sub
rw = clng(ans)
sPath = "C:\Myfolder\"
v = array("Book1.xls","mybook.xls","yourbook.xls", . . .)
for i = lbound(v) to ubound(v)
set bk = workbook.Open(sPath & v(i))
bk.Worksheets(1).Rows(j).Insert
bk.Close Savechanges:=True
Next
End Sub


"LPS" wrote:

Using Excel 2000, I have 8 workbooks, one sheet each, which all need the same
row added to the same place in each workbook, but it could be a different
location each time the rows are added (make sense?). For example, today I
may need to add a new row 5 to all 8 workbooks, but tomorrow I may ned to add
a new row 20 to all 8 workbooks. Is there a way to do this quickly, without
having to open each one and manually add the row in?

Any help is appreciated.
--
LPS

--
LPS

  #4   Report Post  
Posted to microsoft.public.excel.programming
LPS LPS is offline
external usenet poster
 
Posts: 108
Default Add New Row to Multiple Workbooks

Thank you for the suggestion but I know little to nothing about macros and
when I run this, the row of code "rw As Long" is highlighted and it give me
the following error:

Compile error:
Statement invalid outside Type block

Do I have to make any changes to the code before I use it?

Many thanks for your patience,
--
LPS


"Tom Ogilvy" wrote:

Sub UpdateWorkbooks()
Dim sPath as String, v as Variant
Dim bk as Workbook, i as Long
Dim ans as Variant
rw as Long

ans = Application.Inputbox("Enter the row to add",type:=1)
if ans = false then exit sub
rw = clng(ans)
sPath = "C:\Myfolder\"
v = array("Book1.xls","mybook.xls","yourbook.xls", . . .)
for i = lbound(v) to ubound(v)
set bk = workbook.Open(sPath & v(i))
bk.Worksheets(1).Rows(j).Insert
bk.Close Savechanges:=True
Next
End Sub


"LPS" wrote:

Using Excel 2000, I have 8 workbooks, one sheet each, which all need the same
row added to the same place in each workbook, but it could be a different
location each time the rows are added (make sense?). For example, today I
may need to add a new row 5 to all 8 workbooks, but tomorrow I may ned to add
a new row 20 to all 8 workbooks. Is there a way to do this quickly, without
having to open each one and manually add the row in?

Any help is appreciated.
--
LPS

--
LPS

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Add New Row to Multiple Workbooks

I got interrupted and sent it before I had a chance to look it over. That is
caused by a typo. You should just need to put your workbook names in inplace
of the a.xls, b.xls and change the spath= to refer to the folder where you
workbooks are located. You might want to make a dummy path and make a copy
of them there to insure the macro does what you want and doesn't screw up the
originals.

Sub UpdateWorkbooks()
Dim sPath As String, v As Variant
Dim bk As Workbook, i As Long
Dim ans As Variant
Dim rw As Long

ans = Application.InputBox("Enter the row to add", Type:=1)
If ans = False Then Exit Sub
rw = CLng(ans)
sPath = "C:\Myfolder\"
v = Array("a.xls", "b.xls", "c.xls", _
"d.xls", "e.xls", "f.xls", _
"g.xls", "h.xls")
For i = LBound(v) To UBound(v)
Set bk = Workbooks.Open(Filename:=sPath & v(i))
bk.Worksheets(1).Rows(rw).Insert
bk.Close Savechanges:=True
Next
End Sub

after making those changes, then I would expect it to run.

It should be place in a general module (in the VBE [alt+F11], Insert=Module)

--
Regards,
Tom Ogilvy


"LPS" wrote:

Thank you for the suggestion but I know little to nothing about macros and
when I run this, the row of code "rw As Long" is highlighted and it give me
the following error:

Compile error:
Statement invalid outside Type block

Do I have to make any changes to the code before I use it?

Many thanks for your patience,
--
LPS


"Tom Ogilvy" wrote:

Sub UpdateWorkbooks()
Dim sPath as String, v as Variant
Dim bk as Workbook, i as Long
Dim ans as Variant
rw as Long

ans = Application.Inputbox("Enter the row to add",type:=1)
if ans = false then exit sub
rw = clng(ans)
sPath = "C:\Myfolder\"
v = array("Book1.xls","mybook.xls","yourbook.xls", . . .)
for i = lbound(v) to ubound(v)
set bk = workbook.Open(sPath & v(i))
bk.Worksheets(1).Rows(j).Insert
bk.Close Savechanges:=True
Next
End Sub


"LPS" wrote:

Using Excel 2000, I have 8 workbooks, one sheet each, which all need the same
row added to the same place in each workbook, but it could be a different
location each time the rows are added (make sense?). For example, today I
may need to add a new row 5 to all 8 workbooks, but tomorrow I may ned to add
a new row 20 to all 8 workbooks. Is there a way to do this quickly, without
having to open each one and manually add the row in?

Any help is appreciated.
--
LPS

--
LPS



  #6   Report Post  
Posted to microsoft.public.excel.programming
LPS LPS is offline
external usenet poster
 
Posts: 108
Default Add New Row to Multiple Workbooks

Thank you SO much. It is working perfectly. I really appreciate the help.
--
LPS


"Tom Ogilvy" wrote:

I got interrupted and sent it before I had a chance to look it over. That is
caused by a typo. You should just need to put your workbook names in inplace
of the a.xls, b.xls and change the spath= to refer to the folder where you
workbooks are located. You might want to make a dummy path and make a copy
of them there to insure the macro does what you want and doesn't screw up the
originals.

Sub UpdateWorkbooks()
Dim sPath As String, v As Variant
Dim bk As Workbook, i As Long
Dim ans As Variant
Dim rw As Long

ans = Application.InputBox("Enter the row to add", Type:=1)
If ans = False Then Exit Sub
rw = CLng(ans)
sPath = "C:\Myfolder\"
v = Array("a.xls", "b.xls", "c.xls", _
"d.xls", "e.xls", "f.xls", _
"g.xls", "h.xls")
For i = LBound(v) To UBound(v)
Set bk = Workbooks.Open(Filename:=sPath & v(i))
bk.Worksheets(1).Rows(rw).Insert
bk.Close Savechanges:=True
Next
End Sub

after making those changes, then I would expect it to run.

It should be place in a general module (in the VBE [alt+F11], Insert=Module)

--
Regards,
Tom Ogilvy


"LPS" wrote:

Thank you for the suggestion but I know little to nothing about macros and
when I run this, the row of code "rw As Long" is highlighted and it give me
the following error:

Compile error:
Statement invalid outside Type block

Do I have to make any changes to the code before I use it?

Many thanks for your patience,
--
LPS


"Tom Ogilvy" wrote:

Sub UpdateWorkbooks()
Dim sPath as String, v as Variant
Dim bk as Workbook, i as Long
Dim ans as Variant
rw as Long

ans = Application.Inputbox("Enter the row to add",type:=1)
if ans = false then exit sub
rw = clng(ans)
sPath = "C:\Myfolder\"
v = array("Book1.xls","mybook.xls","yourbook.xls", . . .)
for i = lbound(v) to ubound(v)
set bk = workbook.Open(sPath & v(i))
bk.Worksheets(1).Rows(j).Insert
bk.Close Savechanges:=True
Next
End Sub


"LPS" wrote:

Using Excel 2000, I have 8 workbooks, one sheet each, which all need the same
row added to the same place in each workbook, but it could be a different
location each time the rows are added (make sense?). For example, today I
may need to add a new row 5 to all 8 workbooks, but tomorrow I may ned to add
a new row 20 to all 8 workbooks. Is there a way to do this quickly, without
having to open each one and manually add the row in?

Any help is appreciated.
--
LPS

--
LPS

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
How do I move multiple tabs in multiple workbooks to a master? teelee Excel Worksheet Functions 3 October 15th 09 05:03 PM
Updating Workbooks from multiple links Workbooks TimJames Excel Worksheet Functions 1 December 15th 07 03:34 PM
macro: copy multiple workbooks to multiple tabs in single book Michael Excel Programming 0 July 14th 06 04:53 PM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 1 May 13th 06 12:28 PM
adding certain cells in multiple worksheets in multiple workbooks Stephen via OfficeKB.com Excel Worksheet Functions 1 February 4th 05 08:31 PM


All times are GMT +1. The time now is 10:35 AM.

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

About Us

"It's about Microsoft Excel"