Zaichik123
Technical User
Hi,
I have a report that I need to split down into several sheets within the same workbook. I've already developed the majority of the code, but am struggling to add the correct number of sheets and then copy info into the 'next sheet'??
Dim strDept As String
Dim strGrp As String
Dim strRmNum As String
Dim strRmName As String
Dim strPrevDept As String
Dim strPrevGrp As String
Dim strPrevRmNum As String
Dim strPrevRmName As String
Dim Row As Long
Dim BlankRow As Long
Do
Row = Row + 1
Range("A" & Row).Select
' locate beginning of data
If ActiveCell.FormulaR1C1 = "Dept" Then Exit Do
Loop
Do
DoEvents
Row = Row + 1
Range("A" & Row).Select
strDept = LCase$(ActiveCell.FormulaR1C1)
Range("B" & Row).Select
strGrp = LCase$(ActiveCell.FormulaR1C1)
Range("C" & Row).Select
strRmNum = LCase$(ActiveCell.FormulaR1C1)
Range("D" & Row).Select
strRmName = LCase$(ActiveCell.FormulaR1C1)
Range("E" & Row).Select
strRmName = LCase$(ActiveCell.FormulaR1C1)
If strDept = "" And strGrp = "" And strRmNum = ""
(here's where I'm having trouble...)
Then
Sheets("Equipment_by_Room").Select
Sheets.Add
' if have found more than 10 consequtive blank rows then have completed all data
If BlankRow = 10 Then Exit Do
Else
BlankRow = 0
End If
If strDept = strPrevDept _
And strGrp = strPrevGrp _
And strRmNum = strPrevRmNum _
And strRmName = strPrevRmName Then ' this row has the same details as the row before
(here's where I'm having trouble...)
Range("A" & Row, "Z" & Row).Select
Selection.Copy
ActiveSheet.Paste
Else ' commencing rows for the next room
strPrevDept = strDept
strPrevGrp = strGrp
strPrevRmNum = strRmNum
strPrevRmName = strRmName
End If
Please help!
I have a report that I need to split down into several sheets within the same workbook. I've already developed the majority of the code, but am struggling to add the correct number of sheets and then copy info into the 'next sheet'??
Dim strDept As String
Dim strGrp As String
Dim strRmNum As String
Dim strRmName As String
Dim strPrevDept As String
Dim strPrevGrp As String
Dim strPrevRmNum As String
Dim strPrevRmName As String
Dim Row As Long
Dim BlankRow As Long
Do
Row = Row + 1
Range("A" & Row).Select
' locate beginning of data
If ActiveCell.FormulaR1C1 = "Dept" Then Exit Do
Loop
Do
DoEvents
Row = Row + 1
Range("A" & Row).Select
strDept = LCase$(ActiveCell.FormulaR1C1)
Range("B" & Row).Select
strGrp = LCase$(ActiveCell.FormulaR1C1)
Range("C" & Row).Select
strRmNum = LCase$(ActiveCell.FormulaR1C1)
Range("D" & Row).Select
strRmName = LCase$(ActiveCell.FormulaR1C1)
Range("E" & Row).Select
strRmName = LCase$(ActiveCell.FormulaR1C1)
If strDept = "" And strGrp = "" And strRmNum = ""
(here's where I'm having trouble...)
Then
Sheets("Equipment_by_Room").Select
Sheets.Add
' if have found more than 10 consequtive blank rows then have completed all data
If BlankRow = 10 Then Exit Do
Else
BlankRow = 0
End If
If strDept = strPrevDept _
And strGrp = strPrevGrp _
And strRmNum = strPrevRmNum _
And strRmName = strPrevRmName Then ' this row has the same details as the row before
(here's where I'm having trouble...)
Range("A" & Row, "Z" & Row).Select
Selection.Copy
ActiveSheet.Paste
Else ' commencing rows for the next room
strPrevDept = strDept
strPrevGrp = strGrp
strPrevRmNum = strRmNum
strPrevRmName = strRmName
End If
Please help!