VBA: Copy from one range to another without ClipBoard

Bill Bisco

Active Member
Joined
Aug 8, 2007
Messages
446
Hi all. All I want to do is copy one column of data from one worksheet to another without using the Clipboard. I can't get my line highlighted in red to work. Can you help?

Code:
Dim Sws As Worksheet, Cws As Worksheet 'Starting Worksheet, Copy Worksheet
Dim Sr As Integer, Cr As Integer    'Starting Worksheet Row, Copy Worksheet Row
Dim Sc As Integer, Cc As Integer    'Starting Worksheet Column, Copy Worksheet Column
Dim Clr As Long 'Copy the last row of the Worksheet
Dim Str As Long 'Starting worksheet total rows
Dim Sar As Long 'Starting worksheet adjusted rows
Set Sws = Sheets("MaterialFlow")
Set Cws = Sheets("Input PFEP")

Sr = 8
Sc = 4
Cr = 2
Cc = 15
Clr = Cells(Rows.Count, Cc).End(xlUp).Row

'Sws.Range(Cells(Sr, Sc), Cells(Sr, Sc)) = Cws.Range(Cells(Cr, Cc), Cells(Clr, Cc))
Str = Clr - Cr
Sar = Str - Sr
[COLOR=#ff0000]Sws.Range(Cells(Sr, Sc), Cells(Sar, Sc)) = Cws.Range(Cells(Cr, Cc), Cells(Clr, Cc))[/COLOR]
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You're also not properly qualifying everything:

Code:
Sws.Range(sws.Cells(Sr, Sc), sws.Cells(Sar, Sc)).value = Cws.Range(cws.Cells(Cr, Cc), cws.Cells(Clr, Cc)).value
 
Upvote 0
You're also not properly qualifying everything:

Code:
Sws.Range(sws.Cells(Sr, Sc), sws.Cells(Sar, Sc)).value = Cws.Range(cws.Cells(Cr, Cc), cws.Cells(Clr, Cc)).value
Good point! I didn't even notice that.
 
Upvote 0
Thank you both!

I ended up having to modify the code again to this:

Sws.Range(Sws.Cells(Sr, Sc), Sws.Cells(Sar, Sc)).Value = Cws.Range(Cws.Cells(Cr, Cc), Cws.Cells(Clr, Cc)).Value

I forgot that you have to enter in the Worksheet name again for R1C1 Format!
 
Upvote 0

Forum statistics

Threads
1,215,577
Messages
6,125,637
Members
449,242
Latest member
Mari_mariou

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