EliseFreedman
Programmer
I am working on a fairly large spreadsheet.
I would like to filter a range and then copy the value in the first row of one of the columns of this range into the remaining rows of that column.
I managed to create the following macro
<code>
Range("A2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="Y"
Range("Z45").Select
ActiveCell.FormulaR1C1 = "1"
Range("Z45").Select
Selection.Copy
Range("Z108:Z542").Select
ActiveSheet.Paste
Range("AA45:AA542").Select
Selection.Interior.ColorIndex = 37
ActiveWindow.ScrollRow = 217
ActiveWindow.ScrollRow = 143
ActiveWindow.ScrollRow = 136
ActiveWindow.ScrollRow = 104
ActiveWindow.ScrollRow = 45
Selection.Font.ColorIndex = 37
Range("AA45").Select
Selection.AutoFilter Field:=1
</code>
It may not be the same range of cells each time so how can i change the code so that it automatically goes to the first cell in a column in the range and then copies the value to the remaining rows.
Also how do i use code to select the entire filtered range where the cells included within the range might change.
I would like to filter a range and then copy the value in the first row of one of the columns of this range into the remaining rows of that column.
I managed to create the following macro
<code>
Range("A2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="Y"
Range("Z45").Select
ActiveCell.FormulaR1C1 = "1"
Range("Z45").Select
Selection.Copy
Range("Z108:Z542").Select
ActiveSheet.Paste
Range("AA45:AA542").Select
Selection.Interior.ColorIndex = 37
ActiveWindow.ScrollRow = 217
ActiveWindow.ScrollRow = 143
ActiveWindow.ScrollRow = 136
ActiveWindow.ScrollRow = 104
ActiveWindow.ScrollRow = 45
Selection.Font.ColorIndex = 37
Range("AA45").Select
Selection.AutoFilter Field:=1
</code>
It may not be the same range of cells each time so how can i change the code so that it automatically goes to the first cell in a column in the range and then copies the value to the remaining rows.
Also how do i use code to select the entire filtered range where the cells included within the range might change.