LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default File open and close, get some data

The situation:

In file test.xls

sheet1A1: in a formula there is the filename (including dir). For example:
C:\test\test.xls
sheet1A2: in a formula there is the filename of data.xls (including dir).
For example: C:\test\data.xls

The files are placed with a setup, so the dir "test" can be changed to
anything the user prefers.

In file data.xls (password protected, "ABC"):

sheet1B4:D20: some data I want to copy. Destination: test.xls sheet2 C1:E16,
so: selection cell: C1.

I would like to know how to write macro that opens data.xls, copies the data
to test.xls, closes data.xls.

I have this (nor ready yet), but an error occured. The first part (opening
and copying) works fine.

Sub Macro1()
Dim GJ
GJ = Range("Sheet1!A1").Value
Dim GJ2
GJ2 = Range("Sheet1!A2").Value
Workbooks.Open Filename:=GJ, Password:="XYZ"
Range("B4:D20").Select
Selection.Copy
'this doesn't work:
Workbooks ("GJ2").Activate
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues
End Sub

Thanks for helping!


 
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
Close & save a file at set time only IF the file is open Clivey_UK[_5_] Excel Programming 2 May 1st 06 06:19 PM
Close Current File Then Open New file Steve Roberts Excel Programming 1 March 31st 05 02:08 AM
OPen and close file Alvin Hansen[_2_] Excel Programming 5 January 25th 05 01:01 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 02:52 PM.

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"