KEMBAR78
Delete Blank Cells & Sheets Loop | PDF | Computing | Computer Programming
0% found this document useful (0 votes)
24 views3 pages

Delete Blank Cells & Sheets Loop

vba Delete Blank Cells & sheets loop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Delete Blank Cells & Sheets Loop

vba Delete Blank Cells & sheets loop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sub DeleteBlankCells()

Dim A As Long
Dim B As Long

A = ActiveSheet.UsedRange.Columns.CountLarge
B = ActiveSheet.UsedRange.Rows.CountLarge

Range(Columns(A + 1), Columns(A + 1).End(xlToRight)).Delete


Range(Rows(B + 1), Rows(B + 1).End(xlDown)).Delete

msgbox "Done"

End Sub

Sub WorksheetLoop()

Dim WS_Count As Integer


Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count

For I = 3 To WS_Count 'The sheet number you want to start the loop
Worksheets(I).Activate
'Start of the code

With ActiveWorkbook.Worksheets(I)

.Range("I1").Value = "Evidence Rcvd"


.Range("I2").Select
.Columns("I:I").EntireColumn.AutoFit
.UsedRange.Select
.Range("I2").Activate
End With

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With ActiveWorkbook.Worksheets(I)

.Range("H1").Copy
.Range("I1").Select
End With

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _


SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&18 &A _HK"
.RightHeader = ""
.LeftFooter = "BBVA Confidential"
.CenterFooter = "7/25/2017"
.RightFooter = "Page &P"
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _


IgnorePrintAreas:=False

'End of your code


Next I

End Sub

You might also like