Copy rows and paste text not formulas.

sdsdub

New Member
Joined
Jan 3, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have code that works exactly how I want it to EXCEPT it pastes formulas (vlookups, lookups, concatenates, adding vales from one column to another, etc...) instead of the text/values in the cells.
I am copying rows from a worksheet into a different worksheet and pasting it in the first empty row.

Sub GetData()
Dim sh4 As Worksheet, sh5 As Worksheet, lr As Long, rng As Range
Set sh4 = Sheets("CopySheet")
Set sh5 = Sheets("PasteSheet")
lr = sh4.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh4.Range("A2:A" & lr)
rng.EntireRow.Copy sh5.Cells(Rows.Count, 1).End(xlUp)(2)
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi & welcome to MrExcel.
How many columns are you copying?
 
Upvote 0
Hello! Thanks for the welcome. I've been using Mr. Excel for a long time and this is the first time I wasn't able to find the answer to a question.

There are 25 columns and 46 rows if that matters as well. I don't think I'll ever have more than 46 rows to copy.
 
Upvote 0
Ok, how about
VBA Code:
Sub GetData()

   Dim sh4 As Worksheet, sh5 As Worksheet, lr As Long, rng As Range
   Set sh4 = Sheets("CopySheet")
   Set sh5 = Sheets("PasteSheet")
   lr = sh4.Cells(Rows.Count, 1).End(xlUp).Row
   Set rng = sh4.Range("A2:A" & lr).Resize(, 25)
   sh5.Cells(Rows.Count, 1).End(xlUp)(2).Resize(rng.Rows.Count, 25).Value = rng.Value
End Sub
 
Upvote 0
Solution
Change your Copy/Paste code from:
Code:
rng.EntireRow.Copy sh5.Cells(Rows.Count, 1).End(xlUp)(2)
to this:
VBA Code:
rng.EntireRow.Copy
sh5.Cells(Rows.Count, 1).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
Oh, sorry, didn't update my page. Hi to all :).
 
Upvote 0
It's always best to use the Value=Value approach, otherwise you can end-up with "blank" cells that contain null-strings.
 
Upvote 0
It's always best to use the Value=Value approach, otherwise you can end-up with "blank" cells that contain null-strings.
Thanks! This did exactly what you said it would. It wasn't essential for what I'm doing but it is a nice bonus.
 
Upvote 0
Change your Copy/Paste code from:
Code:
rng.EntireRow.Copy sh5.Cells(Rows.Count, 1).End(xlUp)(2)
to this:
VBA Code:
rng.EntireRow.Copy
sh5.Cells(Rows.Count, 1).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
Oh, sorry, didn't update my page. Hi to all :).
Thanks! this worked as well as the code in a previous reply. I appreciate your help!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top