Hi,
I found this code to import data it's working good the only problem i found is that only importing upto line (row) 27 how to modify it that can import all the data in those columns (first was missing row one and the last one but fixed it for the first row, but still the problem to import after row 27, much appreciated your help.
here is the code:
I found this code to import data it's working good the only problem i found is that only importing upto line (row) 27 how to modify it that can import all the data in those columns (first was missing row one and the last one but fixed it for the first row, but still the problem to import after row 27, much appreciated your help.
here is the code:
VBA Code:
Sub ImportRawData()
Dim c As Long
Dim Col As Variant
Dim Filename As String
Dim Filepath As Variant
Dim rngBeg As Range
Dim rngEnd As Range
Dim rngDst As Range
Dim rngSrc As Range
Dim rowsize As Long
Dim wkbDst As Workbook
Dim wkbSrc As Workbook
Set wkbDst = ThisWorkbook
Set rngDst = wkbDst.Worksheets("EFT").Range("A4:E4")
Filepath = "C:\Users\jose.rossi\Desktop\NCL EFT_Summary.xlsm"
Filename = "apcbtclz.csv"
On Error Resume Next
Set wkbSrc = Workbooks(Filename)
If Err = 9 Then
If Filepath <> "" Then ChDir Filepath Else ChDir ThisWorkbook.Path
Filename = Application.GetOpenFilename("Excel Workbooks, *.xlsx")
If Filename = "False" Then Exit Sub
Set wkbSrc = Workbooks.Open(Filename)
End If
On Error GoTo 0
' Clear previous data.
rngDst.Resize(rngDst.Parent.UsedRange.Rows.Count).ClearContents
' Import the data.
With wkbSrc.Worksheets("apcbtclz").UsedRange
' Step through the source data columns.
For Each Col In Array("AW", "BO", "BB", "AX", "X")
' Data starts on row 1.
Set rngBeg = .Parent.Cells(1, Col)
' Find the row where the data ends in this column.
Set rngEnd = .Parent.Cells(Rows.Count, Col).End(xlUp)
' Number of rows in this column.
rowsize = rngEnd.Row - rngBeg.Row
If rowsize > 0 Then
Set rngSrc = .Parent.Range(rngBeg, rngEnd)
rngDst.Offset(0, c).Resize(rowsize, 1).Value = rngSrc.Value
End If
' Increment the column offset.
c = c + 1
Next Col
End With
End Sub