View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
voodooJoe voodooJoe is offline
external usenet poster
 
Posts: 43
Default Macro to import from one closed workbook

minor syntax error(s). edit to suit.

Sub X()
srcpath = "C:\SFADB"
srcbook = "ran dom.xls"
srcsheet = "R1"
srcrng = "d4:e5"

With Sheet1.Range(srcrng) 'correct variable and add to with statement so
it applies to copy and pastespec methods as well
.FormulaArray = "='" & srcpath & "\[" & srcbook & "]" & srcsheet &
"'!" & srcrng
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False

End Sub

cheers - voodooJoe


"jermsalerms"
wrote in message
...

I edited the formula to fit but it is giving me a "Compile Error: Syntax
Error"

Here is the formula...am I missing something?

Sub X()
srcpath = "C:\Documents and Settings\user\My
Documents\Spreadsheets\Data"
srcbook = "Mailer List.xls"
srcsheet = "mor01001"
srcrng = "A2:G4001"

With ActiveSheet
.Range(srcrange).FormulaArray = "='" & srcpath & "\[" & srcbook &
"]" & srcsheet & "'!" & srcrng
.Copy
.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False

End Sub


--
jermsalerms
------------------------------------------------------------------------
jermsalerms's Profile:
http://www.excelforum.com/member.php...o&userid=30167
View this thread: http://www.excelforum.com/showthread...hreadid=498548