Hi friends,
I am using the excel for my company billing purpose as it is already coded with the macros of auto-invoice generating and will save in the specified name as in a folder....As the files in the folder consists of the data's about the company name , truck no,materials, G.C.no and amount...so i need to extract the details of the concerned loading details...but i need only the specified details in that bill which will be in random spaces in the bill....but which will be common places in all the bills....
THIS IS THE FORMULA I AM USING....
Sub LoopThroughDirectory()
Dim MyFile As String, Filepath As String, rng As Range, wb As Workbook, i As Long, j As Long
MyFile = Dir("E:\data extract")
Filepath = "E:\data extract"
Do While Len(MyFile) > 0
If MyFile = "MASTER.xlsm" Then
Exit Sub
End If
Set wb = Workbooks.Open(Filepath & MyFile)
With wb.Sheets(1)
rngArr = Array("B7", "B8", "A12", "B12", "C12", "D12", "F12", "H12", "H7", "H8")
j = 0
For i = LBound(rngArr) To UBound(rngArr)
j = j + 1
.Range(rngArr(i)).Copy Workbooks("MASTER.xlsm").Sheets(1).Cells(Rows.Count, j).End(xlUp)(2)
Next
End With
wb.Close
MyFile = Dir
Loop
End Sub
BUT IN THE ABOVE FORMULA THE ROWS AND COLUMNS WILL ADD IF THERE IS A BLANK CELL...BUT SOMETIMES THE MENTIONED RANGE WILL BE A BLANK CELL IN SOME BILLS SO...IN MASTER FILE WHILE COPYING IF THERE IS A BLANK FILE ALSO I NEED THEM TO PASTE IN THE BILL ORDER ONLY NOT IN ANY BLANK CELL...
SO I REQUEST YOU GUYS TO PLEASE GIVE ME SOME SOLUTION FOR IT.....
I am using the excel for my company billing purpose as it is already coded with the macros of auto-invoice generating and will save in the specified name as in a folder....As the files in the folder consists of the data's about the company name , truck no,materials, G.C.no and amount...so i need to extract the details of the concerned loading details...but i need only the specified details in that bill which will be in random spaces in the bill....but which will be common places in all the bills....
THIS IS THE FORMULA I AM USING....
Sub LoopThroughDirectory()
Dim MyFile As String, Filepath As String, rng As Range, wb As Workbook, i As Long, j As Long
MyFile = Dir("E:\data extract")
Filepath = "E:\data extract"
Do While Len(MyFile) > 0
If MyFile = "MASTER.xlsm" Then
Exit Sub
End If
Set wb = Workbooks.Open(Filepath & MyFile)
With wb.Sheets(1)
rngArr = Array("B7", "B8", "A12", "B12", "C12", "D12", "F12", "H12", "H7", "H8")
j = 0
For i = LBound(rngArr) To UBound(rngArr)
j = j + 1
.Range(rngArr(i)).Copy Workbooks("MASTER.xlsm").Sheets(1).Cells(Rows.Count, j).End(xlUp)(2)
Next
End With
wb.Close
MyFile = Dir
Loop
End Sub
BUT IN THE ABOVE FORMULA THE ROWS AND COLUMNS WILL ADD IF THERE IS A BLANK CELL...BUT SOMETIMES THE MENTIONED RANGE WILL BE A BLANK CELL IN SOME BILLS SO...IN MASTER FILE WHILE COPYING IF THERE IS A BLANK FILE ALSO I NEED THEM TO PASTE IN THE BILL ORDER ONLY NOT IN ANY BLANK CELL...
SO I REQUEST YOU GUYS TO PLEASE GIVE ME SOME SOLUTION FOR IT.....