SereneSea
New Member
- Joined
- Feb 2, 2022
- Messages
- 43
- Office Version
- 2016
- Platform
- Windows
Good morning
I am new to VBA and I am using this code from a previous thread, but instead of pasting values I would like to paste links. How can I add this in the code? I tried replacing Sheets("Summary").Cells(Lastrowa, 1).PasteSpecial xlPasteValues with Sheets("Summary").Cells(Lastrowa).Paste Link:=True , but it no longer pastes from all the sheets, just the last sheet. I have 52 sheets so this code will help me tremendously.
Thank you in advance!
I am new to VBA and I am using this code from a previous thread, but instead of pasting values I would like to paste links. How can I add this in the code? I tried replacing Sheets("Summary").Cells(Lastrowa, 1).PasteSpecial xlPasteValues with Sheets("Summary").Cells(Lastrowa).Paste Link:=True , but it no longer pastes from all the sheets, just the last sheet. I have 52 sheets so this code will help me tremendously.
Thank you in advance!
VBA Code:
Sub Copy_Range_From_Sheets()
'Modified 10/12/2021 6:36:48 PM EDT
On Error GoTo M
Application.ScreenUpdating = False
Dim i As Long
Dim ans As String
Dim Lastrow As Long
Dim Lastrowa As Long
Lastrow = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = 6
For i = 2 To Lastrow
ans = Sheets("Master").Cells(i, 1).Value
With Sheets(ans)
.Range("A123:T215").Copy
Sheets("Summary").Cells(Lastrowa, 1).PasteSpecial xlPasteValues
Lastrowa = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row + 1
End With
Next
Application.ScreenUpdating = True
Exit Sub
M:
MsgBox "You tried to use a sheet name that does not exist" & vbNewLine & "Or we had another problem"
Application.ScreenUpdating = True
End Sub