Copy and Paste from one sheet to another or transfer data from one sheet to another.

DanSMT

Board Regular
Joined
Sep 13, 2019
Messages
203
Office Version
  1. 2013
Platform
  1. Windows
All,

I'm trying transfer data from one sheet to another. Doesn't seem to be working.

Worksheets("Sheet1").Cells(Rows.Count, "F2").End(xlDown).Row.Value = Worksheets("Sheet2").Range("B5").Value

Any idea what im missing?:confused:
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about:

Code:
Sub test1()
  Sheets("Sheet1").Range("F" & Sheets("Sheet1").Range("F" & Rows.Count).End(xlUp).Row + 1).Value = Sheets("Sheet2").Range("B5").Value
End Sub
 
Upvote 0
Doesn't appear to be working. I believe reason may because im trying to pull the data from a table because it has a formula that I am calculating to generate numbers. Is there a way to get it to read the last cell in column F of the table?
 
Upvote 0
Try the following for a table

Code:
Sub test1()
  Dim lr As Long, sh As Worksheet
  Set sh = Sheets("Sheet1")
  lr = 2
  Do While sh.Cells(lr, "F") <> ""
    lr = lr + 1
  Loop
  sh.Range("F" & lr).Value = Sheets("Sheet2").Range("B5").Value
End Sub
 
Upvote 0
Doesn't appear to be targeting the table. I end up with no data in the target destination "B5"
 
Upvote 0
Source = last cell in column F of table in sheet 1
Destination = B5 in sheet 2
 
Last edited:
Upvote 0
Im thinking I may need to copy from the cell instead of just transferring the data, because there is a formula in the source cell that generates a number based on a statement if data exists in another cell to generate a number.
 
Upvote 0
Got it!

Worksheets("Sheet 1").Activate
Range("F" & Cells.Rows.Count).End.Select
ActiveCell.Copy
Worksheets("Sheet 2").Activate
Worksheets("Sheet 2").Range("B5").Select
ActiveCell.PasteSpecial Paste:=xlPasteValues
 
Last edited:
Upvote 0
Your initial code is upside down.
Worksheets("Sheet1").Cells(Rows.Count, "F2").End(xlDown).Row.Value = Worksheets("Sheet2").Range("B5").Value

Must be:
Destination = Source

Then
Code:
Sub test1()
  Dim lr As Long, sh As Worksheet
  Set sh = Sheets("Sheet1")
  lr = 2
  Do While sh.Cells(lr, "F") <> ""
    lr = lr + 1
  Loop
  [COLOR=#0000ff]Sheets("Sheet2").Range("B5").Value[/COLOR] = [COLOR=#b22222]sh.Range("F" & lr - 1).Value[/COLOR]
End Sub

Or

Code:
Sub test2()
  [COLOR=#0000ff]Sheets("Sheet2").Range("B5").Value[/COLOR] = [COLOR=#b22222]Sheets("Sheet1").Range("F1").End(xlDown).Value[/COLOR]
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

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