Macro to update active workbook in one folder

M

Mike @ GD

I have a macro to update inventory in the workbook the macro is written in,
however when saved with a new name the macro will not work. How should the
macro be written to update saved files that are kept in the same folder. The
folder name is "Quote Workbook", the file names will range from 630000 to
659999.
 
D

Don Guillett

You should always post your code for comments/suggestions Perhaps

activeworkbook
 
M

Mike @ GD

Sorry...new at this, here's the code

Sub Update()

'
' Update Macro
' Macro recorded 12/15/2008 by micmul
'
Application.ScreenUpdating = False
Workbooks.Open Filename:= _
"C:\Documents and Settings\micmul\Desktop\Quote
Workbook\inventory.xls"
Cells.Select
Selection.Copy
Windows("Template.xls").Activate
Sheets("Inventory").Select
Cells.Select
ActiveSheet.Paste
Windows("inventory.xls").Activate
Range("D15").Select
Application.CutCopyMode = False
ActiveWindow.Close
Range("H19").Select
Sheets("Quote").Select
Application.ScreenUpdating = True

End Sub
 
D

Don Guillett

One way to copy from a workbook to your ACTIVE workbook

Sub copytoactiveworkbook()
mywb = "C:\yourworkbooknamehere.xls"
mysht = "yoursourcesheetnamehere"
myrng = "B73:F79"
Application.ScreenUpdating = False
Workbooks.Open Filename:=mywb
Sheets(mysht).Range(myrng).Copy
ActiveWindow.Close True
Range("E6").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub
 
M

Mike @ GD

Getting a run time error 9, sub script out of range @ point of
"Sheets(mysht).Range(myrng).Copy".

Below is the script as it is.

Sub Update()

'
' Update Macro
' Macro recorded 12/15/2008 by micmul
'
Sub copytoactiveworkbook()
mywb = "C:\Documents and Settings\micmul\Desktop\Quote Workbook\inventory.xls"
mysht = "Inventory"
myrng = "A1:U5511"
Application.ScreenUpdating = False
Workbooks.Open Filename:=mywb
Sheets(mysht).Range(myrng).Copy
ActiveWindow.Close True
Range("E6").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub
 
S

Shane Devenshire

Hi,

Modify Don's code with a couple of DIM statemensts

Sub copytoactiveworkbook()
Dim mywb As String
Dim mysht As String
Dim myrng As String
mywb = "C:\yourworkbooknamehere.xls"
mysht = "yoursourcesheetnamehere"
myrng = "B73:F79"
Application.ScreenUpdating = False
Workbooks.Open Filename:=mywb
Sheets(mysht).Range(myrng).Copy
ActiveWindow.Close True
Range("E6").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub
 
M

Mike @ GD

Shane, & Don,

Thanks for the help, all is working well. The only issue at this point is
the anoying popup's for the clip board, is the a alternative to this, would
their be a difference between the windows and system clipboard???.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top