Solved

Copying from one drive to another

Posted on 2002-03-28
6
171 Views
Last Modified: 2010-05-02
is there a way Visual Basic can copy the value from A1 that is on H:\Forms\RDS_Access.xls to C:\RDS_Access.xls?
The file on drive H would be closed, im not sure if thats a problem.
I know formulas can be linked to another file without that file being opened.
Here is the macro that I wrote BUT I need to change it to copy the value from A1 Cell that will now be on a different drive versus copying from one worksheet tab to another.
Sub Enter_Po_Number()
   Sheets("P.O. Nos").Visible = True
   Sheets("P.O. Nos").Select
   Range("A1").Select
   Selection.Copy
   Sheets("Access & Couplers").Select
   Range("I9").Select
   ActiveSheet.Paste
   Sheets("P.O. Nos").Select
   Rows("1:1").Select
   Application.CutCopyMode = False
   Selection.Delete Shift:=xlUp
   ActiveWindow.SelectedSheets.Visible = False
   Sheets("Access & Couplers").Select
End Sub

0
Comment
Question by:He4Giv
  • 2
  • 2
  • 2
6 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 6904191
use a formula in your C: spreadsheet like:
='H:\Forms\[RDS_Access.xls]Sheet1'!$A$1
0
 

Author Comment

by:He4Giv
ID: 6904257
A formula wont work because once Cell A1 is copied the macro needs to go back to that file and delete Row 1 so that number cant be used again...This form Im using has a macro button that is labeled "Enter P.O.". when users open this form and press the macro button it copies this number from ROW 1 which then has to be deleted so the next number on ROW 2 now moves up to ROW 1 and becomes available.

In this File I have A1 thru A200 filed in with Purchase order numbers and each time the macro button is pressed it copies A1 from that file to this open file then it goes back and deletes ROW 1 (whats on ROW 2 now moves up to ROW 1).

0
 
LVL 45

Expert Comment

by:aikimark
ID: 6904375
1. Instead of using the clipboard, store the PO number in a variable.  Alternatively, you can use the ?datacache? object as a temporary storage area.
2. You will need to open and close the PO workbook.  You can do this either in the target Excel session or use Excel automation.  The former is simpler.
3. Be sure to save the PO-number workbook after deleting the first row.

Example:
application.open "H:\Forms\RDS_Access.xls"
strVar = Activesheet.Cells(1,1).Text
Activesheet.rows(1).delete
application.close save:=True     'you need to verify the syntax
activesheet.cells(1,1) = strVar
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
ID: 6904571
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6904572
0
 

Author Comment

by:He4Giv
ID: 6905982
Very informative to show examples from Microsoft's library
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question