Enzo_Matrix
Board Regular
- Joined
- Jan 9, 2018
- Messages
- 113
I use several subs for the file I maintain and an odd bug has started happening despite no change to the code. The rows that have data in them are supposed to be underlined as there are 10 columns of data and when it's printed out it is easier to read.
The issue is that there are blank rows below my tables that are being underlined and the number of rows increases each time I run my sub, despite the contents being cleared each time the "Sub FilterCopy()" is run.
This is designed to underline rows that have data in them using the date column as a point of reference.
This filters my main data sheet and then copies the information into the various sheets I have established.
There is a lot more to the subs I am using, but I think these two are the main parts that may be causing an issue. I can post the entire code if need be.
Please help if possible.
The issue is that there are blank rows below my tables that are being underlined and the number of rows increases each time I run my sub, despite the contents being cleared each time the "Sub FilterCopy()" is run.
This is designed to underline rows that have data in them using the date column as a point of reference.
Code:
'Underlining cells based on date range
With Range("A5:I100").SpecialCells(xlConstants).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
This filters my main data sheet and then copies the information into the various sheets I have established.
Code:
Sub FilterCopy()
Dim Ary As Variant
Dim i As Long
Dim Sht As Variant
Ary = Array("Weld", "Composite", "Rubber", "Repairs")
For Each Sht In Ary
Sheets(Sht).UsedRange.ClearContents
Next Sht
With Sheets("Data")
If .AutoFilterMode Then .AutoFilterMode = False
For i = 0 To UBound(Ary)
.Range("A4").AutoFilter 1, Ary(i)
On Error Resume Next
.UsedRange.Offset(1).SpecialCells(xlVisible).Copy Sheets(Ary(i)).Range("A" & Rows.Count).End(xlUp).Offset(4)
On Error GoTo 0
Next i
.AutoFilterMode = False
End With
End Sub
There is a lot more to the subs I am using, but I think these two are the main parts that may be causing an issue. I can post the entire code if need be.
Please help if possible.