I am new to VBA and am struggling to find the code for this simple action through the existing forum posts. If it is possible to assist me it would be much appreciated.
I have a named range on Sheet1 ("Sourcedata") referring to cells B10 to N10. I would like to copy the data in the range and paste as values into the first empty cell in a column range on Sheet2 (B10:B40). I have tried the following code but it does not work. Thanks in advance!
I have a named range on Sheet1 ("Sourcedata") referring to cells B10 to N10. I would like to copy the data in the range and paste as values into the first empty cell in a column range on Sheet2 (B10:B40). I have tried the following code but it does not work. Thanks in advance!
Code:
Sub Copy_Opportunity()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("Sheet1")
Set pasteSheet = Worksheets("Sheet2")
copySheet.Range("Sourcedata").Copy
pasteSheet.Activate
If pasteSheet.Range("B10:B40").Cells(1, 1).Value <> "" Then
Set rngDst = pasteSheet.Range("B10:B40").Cells(1, 1).Offset(Range("B10:B40").Rows.Count - 1).End(xlUp).Offset(1)
Set rngDst = pasteSheet.Range("B10:B40").Cells(1, 1)
End If
Selection.PasteSpecial Paste:=xlPasteValues
End Sub