Hello
I use a vba script from this forum and i need two modifications
1. i need script to extract data from files but script extract data and write just in one colums one under the other
exemple if i extract data from file1.xlsm what i extract to write in collum A, file2.xlsm write in collum B, files3.xlsm write in collum C etc
2. i need at this script to ignore empty space
example i extract data from a file and in Collum i have 2 lines it extract "r" lines not all from la first empty line ( 2 )
my code
I use a vba script from this forum and i need two modifications
1. i need script to extract data from files but script extract data and write just in one colums one under the other
exemple if i extract data from file1.xlsm what i extract to write in collum A, file2.xlsm write in collum B, files3.xlsm write in collum C etc
2. i need at this script to ignore empty space
example i extract data from a file and in Collum i have 2 lines it extract "r" lines not all from la first empty line ( 2 )
my code
VBA Code:
Public Sub centralizareMeniu()
Dim folderPath As String
Dim fileName As String
Dim destCell As Range, r As Long
Dim fromWorkbook As Workbook
'Folder containing the workbooks
folderPath = Application.ActiveWorkbook.Path
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
With ThisWorkbook.ActiveSheet
Set destCell = .Cells(.Rows.Count, "A").End(xlUp)
If Not IsEmpty(destCell.Value) Then Set destCell = destCell.Offset(1)
End With
'Open file names matching *.xls
fileName = Dir(folderPath & "*NIR*.xlsm")
r = 0
Do While fileName <> vbNullString
Set fromWorkbook = Workbooks.Open(folderPath & fileName)
destCell.Offset(r).Resize(15, 10).Value = fromWorkbook.Worksheets("db").Range("A1:J15").Value
r = r + 15
fromWorkbook.Close savechanges:=False
DoEvents
'Get next file name
' Cells.Replace "#N/A", "", xlWhole
fileName = Dir
Loop
MsgBox "Finished"
End Sub