matttclark
Technical User
Hello,
I am a VBA n00b woudl appreciate any help. In excel 2003 the team has a list that is used to track planned expenses for the entire year. Each row is a record of one planned expense request, ie. Travel, equipment, supplies, etc.
The list starts in row 3 and data is in columns (A-AB) where the first four columns are
A=Dept B=Fiscal Qtr C=Month D= requestors name
Weekly, a report is created from the list by autofiltering the list on column C (month). Then a macro is run to sort the data and hide certain columns and rows 1&2 which are notes rows.
The first sort criteria when the report is created is on column A (Dept) in ascending order. The values in column A are all numerical, i.e 2400, 2410, 2420, etc.
Now the boss wants to call out on her report where the Dept (column A) values change in the filtered list to make it easier for her to scan the report list.
Presently this is done by manually underlining the last row showing for each team, ie. If there are 10 entries for team 2400, then the last row of team 2400 is manually underlined, then if there are 8 entries for team 2410, the 8th entry in underlined, etc.
So I have cobbled together some code from different sources and made soem changes on my own to try to automagically underline the last visible row in the filtered list for each Dept. However it reads the whole list and not the filtered values. Is there a way to get this to work on a filtered list.
Here is the code I am using:
I am a VBA n00b woudl appreciate any help. In excel 2003 the team has a list that is used to track planned expenses for the entire year. Each row is a record of one planned expense request, ie. Travel, equipment, supplies, etc.
The list starts in row 3 and data is in columns (A-AB) where the first four columns are
A=Dept B=Fiscal Qtr C=Month D= requestors name
Weekly, a report is created from the list by autofiltering the list on column C (month). Then a macro is run to sort the data and hide certain columns and rows 1&2 which are notes rows.
The first sort criteria when the report is created is on column A (Dept) in ascending order. The values in column A are all numerical, i.e 2400, 2410, 2420, etc.
Now the boss wants to call out on her report where the Dept (column A) values change in the filtered list to make it easier for her to scan the report list.
Presently this is done by manually underlining the last row showing for each team, ie. If there are 10 entries for team 2400, then the last row of team 2400 is manually underlined, then if there are 8 entries for team 2410, the 8th entry in underlined, etc.
So I have cobbled together some code from different sources and made soem changes on my own to try to automagically underline the last visible row in the filtered list for each Dept. However it reads the whole list and not the filtered values. Is there a way to get this to work on a filtered list.
Here is the code I am using:
Code:
Dim intRowval As Integer, intLastRowval As Integer
Dim ws As Worksheet
' Get the row number of the last row of data
intLastRowval = Cells(Rows.Count, "A").End(xlUp).Row
' Row 3 is column headings, so start on the 4th row of data
For intRowval = 4 To intLastRowval
' If the value in column A (=1) has changed from the previous row value
If Cells(intRowval, 1) <> Cells(intRowval - 1, 1) Then
' Choose which cells to underline, i.e. from column 1 to 14
With Range(Cells(intRowval - 1, 1), Cells(intRowval - 1, 14)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = vbBlack
End With
End If
Next intRowval
End Sub