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
|