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
Bookmarks