+ Reply to Thread
Results 1 to 2 of 2

Macro to transfer data between excel files

  1. #1
    Registered User
    Join Date
    05-19-2005
    Posts
    7

    Macro to transfer data between excel files

    Hi,
    I'm new to whole concept of programming macros...

    I am trying to create a macro that uses users inputs from input boxes to obtain row and file name information inorder to tranfer data from one excel file to another. I tried to record a macro fist to test it out...however it will not work with the specified user inputs.

    Here is my code:

    'Selecting desired row to copy input
    stRowColumn = "A" & stRowNumber
    Range(stRowColumn).Select
    'Obtaining cell to input from other file
    stRowData = "R" & stDataRow
    stRowColumnData = stRowData & "C1"

    ActiveCell.FormulaR1C1 = "='[stFileName]sheet1'!stRowColumnData"

    stRowNumber,stDataRow,and stFilename are all user inputs stored as strings.

    Any help would be greatly appreciated!

    Dani

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    enter the complete file path with filename, enter row number, it should single row number for now.


    try this macro


    Sub macro()
    Dim file_name, p_file, w_row, temp As Variant
    file_name = InputBox("enter complete filename with path")
    w_row = InputBox("enter a row number to copy")
    p_file = ActiveWorkbook.Name
    Workbooks.Open Filename:=file_name
    temp = ActiveWorkbook.Name
    Rows(w_row & ":" & w_row).Select
    Selection.Copy
    Workbooks(p_file).Activate
    Range("a1").Select
    ActiveSheet.Paste
    Workbooks(temp).Activate
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    Workbooks(p_file).Activate
    Range("a1").Select


    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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