+ Reply to Thread
Results 1 to 3 of 3

Excel Macro Copy Alph Numberic Data from a Closed CSV File to an Active Excel WorkBook

  1. #1
    Registered User
    Join Date
    04-29-2016
    Location
    india
    MS-Off Ver
    2009
    Posts
    1

    Excel Macro Copy Alph Numberic Data from a Closed CSV File to an Active Excel WorkBook

    Hi i am trying to Pull data from a Closed CSV file (MktReport.csv) on to a Active Excel Work Book (test).Both files will be on same location.

    I am being able to pull alphabetical data but number data is giving error #REF!

    Plz Help

    Below is the code:

    Option Explicit

    Sub GetDataDemo()

    Dim FilePath$, Row&, Column&, Address$

    'change constants & FilePath below to suit
    '**************************************
    Const FileName$ = "MktReport.csv"
    Const SheetName$ = "MktReport"
    Const NumRows& = 10
    Const NumColumns& = 10
    FilePath = ActiveWorkbook.Path & "\"
    '**************************************

    DoEvents
    Application.ScreenUpdating = False
    If Dir(FilePath & FileName) = Empty Then
    MsgBox "The file " & FileName & " was not found", , "File Doesn't Exist"
    Exit Sub
    End If
    For Row = 1 To NumRows
    For Column = 1 To NumColumns
    Address = Cells(Row, Column).Address
    Cells(Row, Column) = GetData(FilePath, FileName, SheetName, Address)
    Columns.AutoFit
    Next Column
    Next Row
    ActiveWindow.DisplayZeros = False
    End Sub

    Private Function GetData(Path, File, Sheet, Address)
    Dim Data$
    Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
    Range(Address).Range("A1").Address(, , xlR1C1)
    GetData = ExecuteExcel4Macro(Data)
    End Function

    I am being able to pull alphabetical data but number data is giving error #REF!

    guys plz help. i have always depended on you guys help.plz

  2. #2
    Registered User
    Join Date
    04-07-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    34

    Re: Excel Macro Copy Alph Numberic Data from a Closed CSV File to an Active Excel WorkBook

    Could you please attach your sample csv, so that will try my level best to help you

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Excel Macro Copy Alph Numberic Data from a Closed CSV File to an Active Excel WorkBook

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy Select Columns from closed workbook into active workbook
    By 3345james in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-09-2015, 02:04 PM
  2. [SOLVED] Code to copy data from a closed workbook and paste in active workbook using named range.
    By paullie1912 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2014, 02:38 AM
  3. Run Macro in closed workbook and copy specific coloumn in active workbook
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2013, 03:43 AM
  4. Copy range from closed excel workbook into master file + finding next empty row
    By ralphmeys in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2013, 12:56 PM
  5. Copy worksheet from closed workbook into active/existing workbook.
    By rasikvekaria in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2012, 06:55 AM
  6. Replies: 6
    Last Post: 07-16-2012, 02:12 PM
  7. [SOLVED] (URGENT) Search for matching data, copy and pasting from a closed excel file
    By dani_n88 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-07-2012, 02:31 PM

Tags for this Thread

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