Below code copies a range of cells from multiple cells in a workbook to a Master Sheet however, I need it to copy only the values and not the formulas. I've tried a few things like
CopyRng.Copy With DestSh.Cells(Last + 1, "A")
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End With
but that doesn't work.
The actual code I'm talking about is this:
Option Explicit
Sub CopytoSummary()
Dim wks As Worksheet
Dim CopyRng As Range
Dim DestSht As Worksheet
Dim LastFreeColumn As Long
Dim DestRowNo As Byte
Dim c As Range
'below "with" speed up the macro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'setting the destination as sheet1 you can use sheet name instead
Set DestSht = Sheet18
'looping through each wks in workbook
For Each wks In ActiveWorkbook.Worksheets
'if wks is different than destination will go through
If wks.Name <> DestSht.Name And wks.Name <> "Template" Then
Set wks = wks
'Select source range
With wks
Set CopyRng = .Range("I2, I3, I13, J13, AD13")
End With
With DestSht
'setting the last free destination column
LastFreeColumn = .Cells(1, 1600).End(xlToLeft).Column + 1
DestRowNo = 1
'Copy each cell to Summary
For Each c In CopyRng
c.Copy .Cells(DestRowNo, LastFreeColumn)
DestRowNo = DestRowNo + 1
Next c
'column width
.Columns(LastFreeColumn).ColumnWidth = 31
End With
End If
Next wks
'set the application back to normal
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
CopyRng.Copy With DestSh.Cells(Last + 1, "A")
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End With
but that doesn't work.
The actual code I'm talking about is this:
Option Explicit
Sub CopytoSummary()
Dim wks As Worksheet
Dim CopyRng As Range
Dim DestSht As Worksheet
Dim LastFreeColumn As Long
Dim DestRowNo As Byte
Dim c As Range
'below "with" speed up the macro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'setting the destination as sheet1 you can use sheet name instead
Set DestSht = Sheet18
'looping through each wks in workbook
For Each wks In ActiveWorkbook.Worksheets
'if wks is different than destination will go through
If wks.Name <> DestSht.Name And wks.Name <> "Template" Then
Set wks = wks
'Select source range
With wks
Set CopyRng = .Range("I2, I3, I13, J13, AD13")
End With
With DestSht
'setting the last free destination column
LastFreeColumn = .Cells(1, 1600).End(xlToLeft).Column + 1
DestRowNo = 1
'Copy each cell to Summary
For Each c In CopyRng
c.Copy .Cells(DestRowNo, LastFreeColumn)
DestRowNo = DestRowNo + 1
Next c
'column width
.Columns(LastFreeColumn).ColumnWidth = 31
End With
End If
Next wks
'set the application back to normal
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub