vinayashwitha
Board Regular
- Joined
- Dec 2, 2009
- Messages
- 73
Hi All,
I am using excel 2007.
I am having below code which collates data from different files in the same folder.
Need help in writing code to find any blank rows and delete the same from the data which is collated using the below code.
Thanks in advance.
Public Sub GetData()
Const FILE_PATH As String = "Path of the folder"
Dim This As Workbook
Dim wb As Workbook
Dim wbName As String
Dim NumRows As Long
Dim InsertAt As Long
Set This = ActiveWorkbook
wbName = Dir(FILE_PATH & "*.xlsx*")
If wbName <> "" Then
InsertAt = 1
Do While wbName <> ""
Set wb = Workbooks.Open(FILE_PATH & wbName)
wb.Worksheets("sheet name").UsedRange.Copy This.Worksheets(1).Cells(InsertAt, "A")
InsertAt = InsertAt + wb.Worksheets("sheet name").UsedRange.Rows.Count
wb.Close savechanges:=False
wbName = Dir
Loop
End If
Set wb = Nothing
Set This = Nothing
End Sub
Regards
Vini
I am using excel 2007.
I am having below code which collates data from different files in the same folder.
Need help in writing code to find any blank rows and delete the same from the data which is collated using the below code.
Thanks in advance.
Public Sub GetData()
Const FILE_PATH As String = "Path of the folder"
Dim This As Workbook
Dim wb As Workbook
Dim wbName As String
Dim NumRows As Long
Dim InsertAt As Long
Set This = ActiveWorkbook
wbName = Dir(FILE_PATH & "*.xlsx*")
If wbName <> "" Then
InsertAt = 1
Do While wbName <> ""
Set wb = Workbooks.Open(FILE_PATH & wbName)
wb.Worksheets("sheet name").UsedRange.Copy This.Worksheets(1).Cells(InsertAt, "A")
InsertAt = InsertAt + wb.Worksheets("sheet name").UsedRange.Rows.Count
wb.Close savechanges:=False
wbName = Dir
Loop
End If
Set wb = Nothing
Set This = Nothing
End Sub
Regards
Vini