ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba (https://www.excelbanter.com/excel-programming/349970-vba.html)

ashw1984

vba
 
hi can anybody tell me how to input data with an input box asking for the
data file and then using the input statement placing the data in the first
four column's of each row until the data has ended this would be a great help
thanks

Bernie Deitrick

vba
 
What is the layout of the data file? Four values then a LF, comma delimited, space or tab
delimited, or is it just....? Details needed.

HTH,
Bernie
MS Excel MVP


"ashw1984" wrote in message
...
hi can anybody tell me how to input data with an input box asking for the
data file and then using the input statement placing the data in the first
four column's of each row until the data has ended this would be a great help
thanks




ashw1984

vba
 
the data file looks like this

10, 87, 98, 98
789, 77, 647, 748
7, 87, 87, 56
and so on

"ashw1984" wrote:

hi can anybody tell me how to input data with an input box asking for the
data file and then using the input statement placing the data in the first
four column's of each row until the data has ended this would be a great help
thanks


the

Bernie Deitrick

vba
 
Sub ImportDataFile()
Dim myFName As Variant
Dim myWkSht As Worksheet

Set myWkSht = ActiveSheet

ChDir "C:\FolderName with data files"
myFName = Application.GetOpenFilename(, , "Select the Data File")

If myFName = False Then
MsgBox "You pressed Cancel"
Exit Sub
Else
Workbooks.OpenText Filename:=myFName, _
StartRow:=1, DataType:=xlDelimited, Comma:=True
End If

Range("A:D").Copy _
myWkSht.Range("A:D")
ActiveWorkbook.Close False

End Sub

HTH,
Bernie
MS Excel MVP


"ashw1984" wrote in message
...
the data file looks like this

10, 87, 98, 98
789, 77, 647, 748
7, 87, 87, 56
and so on

"ashw1984" wrote:

hi can anybody tell me how to input data with an input box asking for the
data file and then using the input statement placing the data in the first
four column's of each row until the data has ended this would be a great help
thanks


the





All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com