View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Macro for Copying

For the next step of your macro, I'm gonna assume that both workbooks are open.
(That can be added later if need be.)

Option Explicit
Sub FrankCopy2()
dim RngToCopy as range
dim DestCell as range

with workbooks("historical actual material pricebased on PO.xls")
.worksheets("somesheetnamehere")
set rngtocopy = .range("AW12:CB60")
end with

with workbooks("M10-7-004 DNP (2).xls").worksheets("somesheetnamehere")
'right after the last used cell in column AW
set destcell = .cells(.rows.count,"AW").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell

end with

You may want:

rngtocopy.copy
destcell.pastespecial paste:=xlpasteformulas


Frank Situmorang wrote:

Hello Sirs,

To be more clear the following is my VBA and my macro is in separate
workbook. Pls. see my comments which are the problems I encounterred. I made
the macro by recording macro, actually I am not an expert in macro.

This is my VBA:
Sub Frankcopy()
'
' Frankcopy Macro
' Macro recorded 1/23/2008 by Frank
'
' Keyboard Shortcut: Ctrl+Shift+F
'Franks comment, below is the workbook on sheet "PO New" and the range is
already fixed
'to be copied to many workbooks, What is the VBA to open the file, here I
opened it first
Windows("historical actual material pricebased on PO.xls").Activate
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
ActiveWindow.ScrollWorkbookTabs Sheets:=-1
Sheets("PO New").Select
Range("AW12:CB60").Select
Selection.Copy
'below is where the rage to be copied to, but what is the VBA to open
many files
' with the same Sheet name"PO new" and then close it after finish
performing copying
Windows("M10-7-004 DNP (2).xls").Activate
' below is the range where the above patterned range to be copied, the
rage is variable
'could go down upto so many lines with the pattern ( number of lines of
P.O) is the same
'could you teach me the VBA for this?, FOR YOUR INFO ON colum AV 12 down
there is number
'where we can use End.xlDown, but I do not know how to make it as the
range is to be
' copied to colum AW (After AV)
Range("AW12:AW60").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub

Thanks in advance
--
H. Frank Situmorang


--

Dave Peterson