Hi all, my currently code imports 1 csv data into sheet 1 and then I have to manually click the button and select the next csv file and import to sheet 2. Im thinking if it is possible to select all 3 csv data and import them to sheet 1, sheet 2 and sheet 3 all at once?
any help is greatly appreciated.
Ouble
any help is greatly appreciated.
Code:
Sub Process()
Dim strCH As String
Dim WrtRec As Boolean
Dim s As String
Dim v As Variant
Dim RowNo As Long
Dim ColNo As Long
Dim Offset As Integer
Dim strFilename As String
strFilename = Application.GetOpenFilename("All Files (*.), *.")
If strFilename = "" Then Exit Sub
Dim FileNum As Integer
FileNum = FreeFile()
Open strFilename For Input As FileNum
Dim ws As Worksheet
Set ws = ActiveWorkbook.ActiveSheet
Do While Not EOF(FileNum)
Line Input #1, s
v = Split(s, vbTab)
If UBound(v) >= 1 Then
v(0) = Trim(Replace(v(0), Chr(34), ""))
Select Case Left(v(0), 3)
Case "Cha" 'Channel
strCH = Trim(Replace(v(1), Chr(34), ""))
Select Case strCH
Case "CH6"
Offset = 1 'Column "A"
Case "CH14"
Offset = 14 'Column "N"
Case Else
Offset = 0
End Select
RowNo = 14
Case "Nu."
WrtRec = True
Case "---"
WrtRec = False
End Select
If WrtRec And (Offset > 0) Then
For ColNo = 0 To UBound(v)
ws.Cells(RowNo, ColNo + Offset) = Trim(Replace(v(ColNo), Chr(34), ""))
Next ColNo
RowNo = RowNo + 1
End If
End If
Loop
Set ws = Nothing
Close (FileNum)
End Sub
Ouble