winstela
New Member
- Joined
- Feb 24, 2019
- Messages
- 28
- Office Version
- 2016
- Platform
- Windows
Hi All,
Hope some can help me, I am trying to copy cells to another workbook but cannot figure out how to just paste the value and format and not the formula
I have tried paste special but I cant seem to make it work but keep getting a compile error
.PasteSpecial Paste:=xlPasteValues
Can you point me in the right direction?
Sub Copy_Paste_Below_Last_Cell()
'Find the last used row in both sheets and copy and paste data below existing data.
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Workbooks.Open "\\mcuk-adc\Prod_Results\01 Value Stream\50 VSM\2022\Kaizen Events\01 SWFF CR5000 Validator\Performance Boards\Daily Output - ABC.xlsx"
'Set variables for copy and destination sheets
Set wsCopy = Workbooks("Perfomance Board New .xlsm").Worksheets("Template")
Set wsDest = Workbooks("Daily Output.xlsx").Worksheets("Data")
'1. Find last used row in the copy range based on data in column A
'lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("t3:t3").Copy _
wsDest.Range("A" & lDestLastRow)
wsCopy.Range("n25:u25").Copy _
wsDest.Range("g" & lDestLastRow)
wsCopy.Range("n5:n5").Copy _
wsDest.Range("r" & lDestLastRow)
wsCopy.Range("g25:h25").Copy _
wsDest.Range("b" & lDestLastRow)
wsCopy.Range("i25:i25").Copy _
wsDest.Range("f" & lDestLastRow)
End Sub
Hope some can help me, I am trying to copy cells to another workbook but cannot figure out how to just paste the value and format and not the formula
I have tried paste special but I cant seem to make it work but keep getting a compile error
.PasteSpecial Paste:=xlPasteValues
Can you point me in the right direction?
Sub Copy_Paste_Below_Last_Cell()
'Find the last used row in both sheets and copy and paste data below existing data.
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Workbooks.Open "\\mcuk-adc\Prod_Results\01 Value Stream\50 VSM\2022\Kaizen Events\01 SWFF CR5000 Validator\Performance Boards\Daily Output - ABC.xlsx"
'Set variables for copy and destination sheets
Set wsCopy = Workbooks("Perfomance Board New .xlsm").Worksheets("Template")
Set wsDest = Workbooks("Daily Output.xlsx").Worksheets("Data")
'1. Find last used row in the copy range based on data in column A
'lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("t3:t3").Copy _
wsDest.Range("A" & lDestLastRow)
wsCopy.Range("n25:u25").Copy _
wsDest.Range("g" & lDestLastRow)
wsCopy.Range("n5:n5").Copy _
wsDest.Range("r" & lDestLastRow)
wsCopy.Range("g25:h25").Copy _
wsDest.Range("b" & lDestLastRow)
wsCopy.Range("i25:i25").Copy _
wsDest.Range("f" & lDestLastRow)
End Sub