Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import from one excel worksheet into another

I currently have a model which really consists of two
workbooks. One workbook is the data input workbook in
which all the data is entered by one person. The second
workbook is used by another person and needs to be able to
import information from the first workbook with a macro.
However, a simple link will not work as I want a macro
that will allow the user to define which workbook to
import the information from as this changes all of the
time. Please help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import from one excel worksheet into another

I used code similar to this for situations similar to yours. I am sur
there may be easier ways to accomplish this task, but I found these tw
options worked for me. This first macro simply opens the OpenFil
dialog box, you select the file you want, and then it opens the fil
you selected. If you hit Cancel in the dialog box, the macro jus
terminates.

Sub Open_File()
Dim strFile As String
strFile = Application.GetOpenFilename("Excel files (*.xl*),*.xl*")
If strFile = False Then Exit Sub
Workbooks.Open FileName:=strFile
End Sub

This second macro allows you to set a standard path. If you keep you
data files in the same folder all the time, it will probably make i
easier for you to just type in the file name. The .xls extension doe
not have to be typed in the InputBox, but it won't hurt if it is.
simple error handler gives the user a message and exits the macro i
the file name typed in does not exist. If you wish, you can separat
out the InputBox command, assign to another variable, and add whateve
other error handling you want to trap.

Sub Open_File2()
Dim strPath As String
On Error GoTo No_File
strPath = "C:\YourPathTo\Data\"
Workbooks.Open FileName:=strPath & InputBox("File Name")
Exit Sub
No_File:
MsgBox "That file does not exits."
End Sub


Just some of the ways I have handled your situation. Let me know i
this helps!


JerryG :

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import from one excel worksheet into another

i tried this function. when i typed filename i got files does not exis
am i supposed to change the path. in the editor.??

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import from one excel worksheet into another

Yes, if you are using the second macro, you must replace
C:\YourPathTo\Data\ with your correct path in the VB editor.


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import from one excel worksheet into another

i used the fisrt macro jerry posted and ran it.. it popped up the open
box and selected my file and got Run-time error 13/ type mismatch


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import from one excel worksheet into another

Sorry, missed some quotes. First macro should be . . .

Sub Open_File()
Dim strFile As String
strFile = Application.GetOpenFilename("Excel files (*.xl*),*.xl*")
If strFile = "False" Then Exit Sub
Workbooks.Open FileName:=strFile
End Sub


JerryG ;)


---
Message posted from http://www.ExcelForum.com/

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
how do i import data from my excel worksheet into quickbooks excel to quickbooks Excel Worksheet Functions 1 February 18th 10 03:44 PM
how do I import act contact into excel worksheet Crocus Excel Discussion (Misc queries) 1 April 30th 08 10:59 PM
can i import a pdf file into an excel worksheet? If so, how? MB Excel Discussion (Misc queries) 1 January 5th 07 01:20 PM
how to import more than 1 text file into the same Excel worksheet. SinnetBS Excel Discussion (Misc queries) 1 June 14th 06 03:14 AM
How do I import several csv files into one excel worksheet? chieftrain Excel Discussion (Misc queries) 10 June 6th 06 08:18 AM


All times are GMT +1. The time now is 03:36 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"