Solved

Copying from one drive to another

Posted on 2002-03-28
6
172 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

828 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