Results 1 to 11 of 11

Read in data from one file to another

Threaded View

bluesurger Read in data from one file to... 05-16-2014, 05:48 AM
bluesurger Re: Read in data from one... 05-16-2014, 07:00 AM
bluesurger Re: Read in data from one... 05-16-2014, 09:20 AM
alansidman Re: Read in data from one... 05-16-2014, 09:43 AM
bluesurger Re: Read in data from one... 05-16-2014, 10:58 AM
bluesurger Re: Read in data from one... 05-17-2014, 02:49 AM
Tinbendr Re: Read in data from one... 05-17-2014, 04:08 AM
bluesurger Re: Read in data from one... 05-17-2014, 06:04 AM
bluesurger Re: Read in data from one... 05-19-2014, 04:33 AM
bluesurger Re: Read in data from one... 05-19-2014, 05:06 AM
Tinbendr Re: Read in data from one... 05-19-2014, 07:05 AM
  1. #1
    Registered User
    Join Date
    05-16-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    78

    Read in data from one file to another

    my Name is Sebastian. I'm from Germany.
    I have to tell my problem here, because the german side is currently down

    my Problem:
    I have 2 Excel files. One with the macro-code and another one.
    The one with the macro is named "Book1.xlsx" and the other one is named "Book2.xlsx".
    The name of the second file (in this case Book2) change weekly. But the name of the sheet in which are my data is always the same (in this case "sheet1").

    For my understanding:
    - I start the macro in Book1.
    - The macro ask me for the other file with the data i need
    - I open the file (Book2 in this case)
    - Now the macro should read out data from Book2(table) an put it into Book1 (table)
    - After read out a area with no entry --> read out should finish or after 16 columns.
    - After read out the files from the table the macro should close the Book2.


    This is my file, can anyone take a look at this?

    Sub test1()
    Dim fileselection As Variant
    
    again:
    fileselection = Application.GetOpenFilename
    
    If fileselection <> False Then
        Workbooks.Open Filename:=fileselection
         Else
        If MsgBox("You chosse no file! Press 'OK' to choose a file, or 'Abbrechen' to cancel.", (vbOKCancel)) = vbOK Then
            GoTo again
            End If
            End If
    
    'readIn 1 column
    
        Dim i As Integer
        For i = 4 To 16
    
        Windows("Book1.xlsx").Activate
        Range("C" & i).Select
        ActiveCell = "='[fileselection]Sheet1 (sel)'!C" & i 
    
    'readIn 2 column
    
        Windows("Book1.xlsx").Activate
        Range("D" & i).Select
        ActiveCell = "='[fileselection]Sheet1 (sel)'!D" & i 
    
    
     Next i
          
    End Sub
    one more question, can i declare two variables? like i & j ?
    Like: i is from 4 to 16 and j is from 6 to 18 ? or should i write "i+2" instead of j ?

    sorry for my bad english. I try my best
    Attached Files Attached Files
    Last edited by alansidman; 05-16-2014 at 09:40 AM. Reason: Code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Read data from other xls file
    By EugeneP in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-31-2010, 07:12 PM
  2. Read .csv file data
    By kistonce in forum Excel General
    Replies: 2
    Last Post: 05-09-2010, 03:03 AM
  3. How to read data from txt file to an array?
    By arthurcheuk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-24-2008, 04:36 AM
  4. Read Data from file
    By ethyl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2008, 01:35 PM
  5. [SOLVED] Read data from anohter XLS file
    By John Whitehead via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 09-06-2005, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1