naveenraja16
New Member
- Joined
- Mar 3, 2016
- Messages
- 10
i have a workbook name as ColorDB and 2 sheets inside that workbook. The Sheets are named as "CNT" and the other one as "PPB". I have a macro button inserted onto the "PPB" sheet. when i click that macro button , i would like to browse and open a .dat file and import the data onto the same sheet "PPB".
Currently i have a code to open in a new workbook separately.
But i would like to know the modification needed to be made to open in the "PPB" sheet itself.
[Sub PPBcolorDBgenerate()Dim myFileNames As Variant
Dim iCtr As Long
myFileNames = Application.GetOpenFilename _
(filefilter:="DAT Files, *.DAT", MultiSelect:=True)
If IsArray(myFileNames) Then
For iCtr = LBound(myFileNames) To UBound(myFileNames)
Workbooks.OpenText filename:=myFileNames(iCtr), _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, FieldInfo:=Array(1, 1)
Next iCtr
End If
Application.StatusBar = False
Application.EnableEvents = True
Application.ScreenUpdating = True
ErrorCheck:
Application.StatusBar = False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub][/CODE]
Currently i have a code to open in a new workbook separately.
But i would like to know the modification needed to be made to open in the "PPB" sheet itself.
[Sub PPBcolorDBgenerate()Dim myFileNames As Variant
Dim iCtr As Long
myFileNames = Application.GetOpenFilename _
(filefilter:="DAT Files, *.DAT", MultiSelect:=True)
If IsArray(myFileNames) Then
For iCtr = LBound(myFileNames) To UBound(myFileNames)
Workbooks.OpenText filename:=myFileNames(iCtr), _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, FieldInfo:=Array(1, 1)
Next iCtr
End If
Application.StatusBar = False
Application.EnableEvents = True
Application.ScreenUpdating = True
ErrorCheck:
Application.StatusBar = False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub][/CODE]