VBA Copy past from one sheet to another

vikas007

New Member
Joined
Mar 3, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
I want to copy the data from sheet"RaW" Column "C" start from 2nd row.. And past it to Sheet "Nicedump" Column "D" first empty. this is continue data entry file so every time first empty will be different.. What will be the VBA code?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try this
VBA Code:
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long

  'Set variables for copy and destination sheets
  Set wsCopy = Workbooks("COPYFROM.XLS").Worksheets("RaW")
  Set wsDest = Workbooks("COPYTO.xls").Worksheets("Nicedump")
    
  '1. Find last used row in the copy range based on data in column A
  lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "c").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, "d").End(xlUp).Offset(1).Row

  '3. Copy & Paste Data
  wsCopy.Range("C2:C" & lCopyLastRow).Copy _
    wsDest.Range("D" & lDestLastRow)
 
Upvote 0
Not working.. Showing dbug at "
'Set variables for copy and destination sheets
Set wsCopy = Workbooks("COPYFROM.XLS").Worksheets("RaW")
 
Upvote 0
if both sheets are in the same workbook change these two lines
Code:
Set wsCopy = Workbooks("COPYFROM.XLS").Worksheets("RaW")
Set wsDest = Workbooks("COPYTO.xls").Worksheets("Nicedump")

to
VBA Code:
Set wsCopy = Worksheets("RaW")
Set wsDest = Worksheets("Nicedump")
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,969
Members
449,059
Latest member
oculus

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