ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy and paste only values (https://www.excelbanter.com/excel-programming/402047-copy-paste-only-values.html)

Jennifer

Copy and paste only values
 
How do i write in a paste special code for only the values? Thank you my dear
gurus.

Sub Post()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")
' find first empty row in database
'iRow = ws.Cells(Rows.Count, 1) .End(xlUp).Offset(1, 0).Row
iRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
Worksheets("Filter").Range("FilterDatabase").Copy ws.Cells(iRow, 1)
end sub
--
Thank you,

Jennifer

Nigel[_2_]

Copy and paste only values
 
ws.Cells(iRow, 1).PasteSpecial Paste:=xlPasteValues

--

Regards,
Nigel




"Jennifer" wrote in message
...
How do i write in a paste special code for only the values? Thank you my
dear
gurus.

Sub Post()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")
' find first empty row in database
'iRow = ws.Cells(Rows.Count, 1) .End(xlUp).Offset(1, 0).Row
iRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
Worksheets("Filter").Range("FilterDatabase").Copy ws.Cells(iRow, 1)
end sub
--
Thank you,

Jennifer



Greg Wilson

Copy and paste only values
 
Commented out is what you were looking for. I prefer to just specify that the
target range value equals the source range value instead. Also note that I
just add 1 to the result of End(xlUp) instead of using Offset. A tad simpler.


Sub Post()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("Database")
iRow = ws.Cells(Rows.Count, 2).End(xlUp).Row + 1
ws.Cells(iRow, 1).Value = _
Worksheets("Filter").Range("FilterDatabase").Value
'Worksheets("Filter").Range("FilterDatabase").Copy
'ws.Cells(iRow, 1).PasteSpecial xlPasteValues
Set ws = Nothing: Set ws2 = Nothing
End Sub

Greg


All times are GMT +1. The time now is 03:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com