Aug 10 2022 02:08 PM
Hello,
I have a spreadsheet with over 100 sheets. I need the value in Cell A14 of each sheet to be pasted to all rows in column A thru the end of the sheet. For example, I need Cell A14 (#A) to go all the way down to A29. The thing is, on each sheet there is a different number of rows. The data always begins in row 14, but I need column A to be pasted til the last row for each sheet regardless of the amount of rows. Also, sometimes there is only data in row 14 so nothing is necessary, but with it being over 100 sheets I would like a VBA that does this for the whole workbook.
->
Aug 10 2022 02:17 PM
Try this macro:
Sub CopyDownA()
Dim LastRow As Long
LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("A14").AutoFill Destination:=Range("A14:A" & LastRow)
End Sub
Aug 10 2022 02:21 PM
Aug 10 2022 02:33 PM
SolutionNew version:
Sub CopyDownA()
Dim LastRow As Long
LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("A15:A" & LastRow).Value = Range("A14").Value
End Sub
Aug 10 2022 02:38 PM
Aug 10 2022 02:58 PM
A version that will loop through ALL worksheets in the active workbook:
Sub CopyDownAll()
Dim Wks As Worksheet
Dim LastRow As Long
For Each Wks In Worksheets
LastRow = Wks.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Wks.Range("A15:A" & LastRow).Value = Wks.Range("A14").Value
Next Wks
End Sub
And one that will loop through the selected sheets only:
Sub CopyDownSelected()
Dim Wks As Worksheet
Dim LastRow As Long
For Each Wks In ActiveWindow.SelectedSheets
LastRow = Wks.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Wks.Range("A15:A" & LastRow).Value = Wks.Range("A14").Value
Next Wks
End Sub
Aug 10 2022 02:33 PM
SolutionNew version:
Sub CopyDownA()
Dim LastRow As Long
LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("A15:A" & LastRow).Value = Range("A14").Value
End Sub