Help me.
I have a workbook that is used on a daily basis to account for all aircraft landing at my station. At the end of the month, we have to clear the workbook out. I have 31 sheets. One for each day of the month, if less are used cool. I also have a totals sheet. On any given "Day" we can have anywhere from 1 to 90 flights landing. Is there a way to have VBA search for a range and clear it on each page, using a macro? Say that on day one we had 30 aircraft land and on day 14 we had 135. At the bottom is a total row, and at the far right is a total column. Can VBA find those columns and rows and clear them? Any help is much appreciated.
02-04-2003 at 01:49 AM
|
biggdady6998 Level: Guest
Re: Find Rowws
Nevermind, I figured it out. I created two loops. One for the sheets and one for the rows. Here is the code
Sub Test2() 'Find rows before Totals row and clear. Leave two rows above.
Const Password = "Customer"
Dim Cells As Boolean
Dim r As Integer, c As Integer
Dim MaxRow As Integer, MinRow As Integer
Dim MaxColumn As Integer, MinColumn As Integer
Dim Sheetmin As Integer, SheetMax As Integer
Dim MyRange As String
Dim Counter As Integer
Dim pctDone As Single
MinRow = "4"
MinColumn = "2"
MaxCell = "19"
r = "4"
c = MinColumn
s = "2"
MaxRow = "300"
Sheetmin = "2"
SheetMax = "33"
If InputBox("Please Input Password", "Authorization Required") <> Password Then
MsgBox "You have input an Incorrect Password", vbCritical + vbOKOnly + vbDefaultButton1, "HAHA, Guess Again!"
Exit Sub
Else
While s <= SheetMax
Sheets(s).Select
MaxRow = "300"
r = "4"
While r <= MaxRow
If Range("B6") = "Totals" Then
MaxRow = "6"
Range("B4:S5").Select
Selection.ClearContents
Range("B4").Select
Else
Rows("6:6").Delete
End If
r = r + 1
Wend
s = s + 1
Wend