Thread
:
Open Workbook in current directory
View Single Post
#
4
Posted to microsoft.public.excel.programming
Elijah
external usenet poster
Posts: 4
Open Workbook in current directory
Thanks Don, Bob
much appreciated.
Elijah
"Don Guillett" wrote in message
...
use thisworkbook.path
--
Don Guillett
SalesAid Software
"Elijah" wrote in message
...
Hi, I'm using 2 workbooks in my forecast model. Can some help with a
macro
to transfer data between the workbooks?
I have so far recorded a copy-paste special macro to transfer data, but
what
I want to do is:
- If the workbook is open then activate the relevant sheet and copy and
paste data between workbooks, otherwise open the relevant workbook.
- Be able to store the 2 workbooks in any directory and still have the
macro
work.
I've tried the following macro - but I get an error with the use of the
Me.
construct:
Sub CopyData()
Dim sFileName As String
sFileName = "SpreadsheetB.xls"
On Error Resume Next
Workbooks("SpreadsheetB.xls").Activate
If Err.Number 0 Then
Workbooks.Open Me.Path & "\" & sFileName
End If
On Error GoTo 0
Sheets("Forecast").Select
Rows("2:270").Select
Selection.Copy
.....
Does anyone tell me what I've done wrong here?
Thanks
Elijah
Reply With Quote
Elijah
View Public Profile
Find all posts by Elijah