#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro

Hello,

I have 2 separate excel files. I want to create a macro in 1st file
which will open the 2nd file, copy the data from the 2nd file and
paste it in the worksheet of the 1st file in a desired location.

My question is: Because the users of these excel files will have the
two files in the any directory, the Macro I designed looks for a
specific directory on the computer where the 2nd file is. Is there I
way that the directory doesn't play a part in where it looks for the
file? I would like to make the users create 1 directory called HRCL
anywhere on their computer and allow the macro to look for the file in
that specific directory. I want the user to have the option to
create the folder and have the files anywhere... as long as it is in a
subfolder called HRCL

This is the way my macro looks so far
Sub opendata2()
'
' opendata2 Macro
' Macro recorded 07/11/2007 by
'

'
ChDir "C:\Documents and Settings\CHDIMA\Desktop\HRCL"
Workbooks.Open Filename:= _
"C:\Documents and Settings\CHDIMA\Desktop\HRCL\HCRL_data.xls"
Range("A2:BD1000").Select
Selection.Copy
Windows("summaryreport-pivot.xls").Activate
Sheets("ZIRN-data").Select
ActiveSheet.Paste
End Sub

ANy help would be appreciated

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro

On Nov 7, 4:16 pm, wrote:
Hello,

I have 2 separate excel files. I want to create a macro in 1st file
which will open the 2nd file, copy the data from the 2nd file and
paste it in the worksheet of the 1st file in a desired location.

My question is: Because the users of these excel files will have the
two files in the any directory, the Macro I designed looks for a
specific directory on the computer where the 2nd file is. Is there I
way that the directory doesn't play a part in where it looks for the
file? I would like to make the users create 1 directory called HRCL
anywhere on their computer and allow the macro to look for the file in
that specific directory. I want the user to have the option to
create the folder and have the files anywhere... as long as it is in a
subfolder called HRCL

This is the way my macro looks so far
Sub opendata2()
'
' opendata2 Macro
' Macro recorded 07/11/2007 by
'

'
ChDir "C:\Documents and Settings\CHDIMA\Desktop\HRCL"
Workbooks.Open Filename:= _
"C:\Documents and Settings\CHDIMA\Desktop\HRCL\HCRL_data.xls"
Range("A2:BD1000").Select
Selection.Copy
Windows("summaryreport-pivot.xls").Activate
Sheets("ZIRN-data").Select
ActiveSheet.Paste
End Sub

ANy help would be appreciated


SOLUTION:

ChDir CStr(ActiveWorkbook.Path)

works like a charm!!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 01:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"