L
Legacy 177844
Guest
Hi, I'm a newbie here but have (almost) got the code to work the way I want save one problem which I'm hoping someone can give me a solution to?
Situation:
8 columns of data with filters
When a filter is selected, the first visible row is identified and each cell value in that row is sent to sheet2 into various pre-determined cell locations (sheet 2 being a summary sheet).
The code does the job except when I select filters to display the first row of data that would be visible if no filters were active.
Code:
Situation:
8 columns of data with filters
When a filter is selected, the first visible row is identified and each cell value in that row is sent to sheet2 into various pre-determined cell locations (sheet 2 being a summary sheet).
The code does the job except when I select filters to display the first row of data that would be visible if no filters were active.
Code:
Code:
Sub tester()
' ' On the active sheet (sheet1) with the autofiler applied,
' ' select the first visible cell of the first row and copy
' ' that value to cell A1 in sheet2.
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(1).Select
Selection.Copy Worksheets("Sheet2").Range("A1")
' ' Return to the active sheet (sheet1) with autofiler applied and
' ' select the second visible cell of the first row and copy
' ' it to cell A2 in sheet2.
Sheets("Sheet1").Select
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(2).Select
Selection.Copy Worksheets("Sheet2").Range("A2")
Sheets("Sheet1").Select
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(3).Select
Selection.Copy Worksheets("Sheet2").Range("A7")
Sheets("Sheet1").Select
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(4).Select
Selection.Copy Worksheets("Sheet2").Range("A8")
Sheets("Sheet1").Select
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(5).Select
Selection.Copy Worksheets("Sheet2").Range("C4")
Sheets("Sheet1").Select
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(6).Select
Selection.Copy Worksheets("Sheet2").Range("D2")
Sheets("Sheet1").Select
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Cells(7).Select
Selection.Copy Worksheets("Sheet2").Range("C6")
' ' Once all the above is complete, return to
' ' the sheet with the autofilter applied and reset
' ' the filters
Sheets("Sheet1").Select
ActiveSheet.ShowAllData
' ' Finally, go to sheet 2 where all the new data has been populated
Sheets("Sheet2").Select
End Sub