Dear all,
I am relatively new to VBA and Macros.
Basically, I am trying to build a database of sorts in which I have 600+ hotel rooms, for each room one sheet. In each sheet I will track the current problems where different departments need to come in and repair these.
Therefore, I want an overview sheet in which all entries are listed that are "ongoing".
This means that all 600+ sheets need to look for entries that have the status "ongoing" in Column E, and then copy these rows to the sheet "overview", obviously underneath eachother.
A: Kamernummer
B: What?
C: Department
D: Action
E: Status
F: Description
G: Date entered
Every time I run the macros, I also want to have it delete the overview, so the entries that may have been completed in the meanwhile, will disappear.
I have found bits and pieces here (such as https://www.mrexcel.com/forum/excel...y-certain-cells-same-row-different-sheet.html and https://www.mrexcel.com/forum/excel...-copy-rows-based-criteria-new-sheet-file.html and https://www.mrexcel.com/forum/excel...ch-multiple-sheets-display-results-sheet.html, but am completely stuck.
What I have so far, from copying bits and pieces, and deleting bits of pieces is this:
But I do feel like I have created now a huge mess that does not belong together.
Is somebody out there that would be able to help me in any way?
Thank you all a lot in advance!!!
I am relatively new to VBA and Macros.
Basically, I am trying to build a database of sorts in which I have 600+ hotel rooms, for each room one sheet. In each sheet I will track the current problems where different departments need to come in and repair these.
Therefore, I want an overview sheet in which all entries are listed that are "ongoing".
This means that all 600+ sheets need to look for entries that have the status "ongoing" in Column E, and then copy these rows to the sheet "overview", obviously underneath eachother.
A: Kamernummer
B: What?
C: Department
D: Action
E: Status
F: Description
G: Date entered
Every time I run the macros, I also want to have it delete the overview, so the entries that may have been completed in the meanwhile, will disappear.
I have found bits and pieces here (such as https://www.mrexcel.com/forum/excel...y-certain-cells-same-row-different-sheet.html and https://www.mrexcel.com/forum/excel...-copy-rows-based-criteria-new-sheet-file.html and https://www.mrexcel.com/forum/excel...ch-multiple-sheets-display-results-sheet.html, but am completely stuck.
What I have so far, from copying bits and pieces, and deleting bits of pieces is this:
But I do feel like I have created now a huge mess that does not belong together.
Code:
Option ExplicitPrivate Sub Main()
Dim intLastColumn As Integer
Dim wksSheetNew As Worksheet
Dim wksSheet As Worksheet
Dim lngLastRow As Long
Dim strFound As String
Dim rngRange As Range
Dim strLink As String
Dim strTMP As String
On Error GoTo Fin
Application.DisplayAlerts = False
For Each wksSheet In ThisWorkbook.Worksheets
'strFound = "Laptops"
If wksSheet.Name <> wksSheetNew.Name Then
Set rngRange = wksSheet.Columns(2).Find(What:=strFound, _
LookIn:=xlValues, LookAt:=xlPart)
If rngRange Is Nothing Then
Else
strLink = rngRange.Value
End If
If Not rngRange Is Nothing Then
strTMP = rngRange.Address
Do
lngLastRow = lngLastRow + 1
wksSheet.Cells(rngRange.Row, rngRange.Column).EntireRow.Copy _
Destination:=wksSheet(2).Cells(lngLastRow, 1)
Set rngRange = wksSheet.Columns(5).FindNext(rngRange)
Loop While rngRange.Address <> strTMP
wksSheetNew.Cells.EntireColumn.AutoFit
End If
End If
Next wksSheet
Fin:
Application.DisplayAlerts = True
If Err.Number <> 0 Then MsgBox "Error: " & _
Err.Number & " " & Err.Description
If strTMP = "" Then
MsgBox "Search term was not found!"
Else
MsgBox "All matching data has been copied."
End If
Set rngRange = Nothing
Set wksSheetNew = Nothing
End Sub
Is somebody out there that would be able to help me in any way?
Thank you all a lot in advance!!!