I am following a YouTube tutorial on VBA for Excel. In one segment of the tutorial, the objective is to copy information from one sheet and paste it into specific cells on a different sheet within the same workbook. The correct piece of code for this process given in this part of the video is:
Public Sub PopPandL()
Dim x As Integer
Dim sheet_title As String
For x = 1 To Worksheets.Count - 1
Worksheets(x).Select
sheet_title = ActiveSheet.Name
Sheets("P&L").Select
Selection.Offset(x * 5 + 2, 0).Select
Selection.Value = sheet_title
Worksheets(x).Select
Range("A1").Select
Selection.CurrentRegion.Copy
Sheets("P&L").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Next x
End Sub
My question concerns the activecell and activesheet components of this code. To experiment, when I try to use:
Selection.Offset(1, 0).Select
Selection.Paste
as an alternative, I get an error saying that the object does not support this property or method. Why is this?