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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

AC PORTA VIA

Board Regular
Joined
Apr 9, 2016
Messages
89
Office Version
  1. 365
Platform
  1. Windows
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)
 

vikas007

New Member
Joined
Mar 3, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Not working.. Showing dbug at "
'Set variables for copy and destination sheets
Set wsCopy = Workbooks("COPYFROM.XLS").Worksheets("RaW")
 

AC PORTA VIA

Board Regular
Joined
Apr 9, 2016
Messages
89
Office Version
  1. 365
Platform
  1. Windows
change COPYFROM.XLS to your actual workbook name
same for COPYTO.xls
 

AC PORTA VIA

Board Regular
Joined
Apr 9, 2016
Messages
89
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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")
 

Watch MrExcel Video

Forum statistics

Threads
1,129,485
Messages
5,636,608
Members
416,929
Latest member
Nitil

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
Top