copy range to another sheet - not working

Oberon70

Board Regular
Joined
Jan 21, 2022
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am having problems with the below code, as I am trying to copy a range to another sheet.

VBA Code:
Dim wb As Workbook
Dim wsData As Worksheet
Dim wsRcpt As Worksheet
Dim lRow As Long
Dim x As Integer
Dim rng As Variant
Dim InvID As Long
Sub Copy_Data_NM()

Set wb = ThisWorkbook


wb.Worksheets("Data").Visible = True
Set wsData = wb.Worksheets("Data")

'Set wsRcpt = wb.Worksheets("Receipted")

lRow = wsData.Cells(Rows.Count, 1).End(xlUp).Row


wb.Sheets.Add after:=wsData

ActiveSheet.Name = "Receipted"
'wb.Worksheets("Data").Visible = False
Set wsRcpt = wb.Worksheets("Receipted")

wsData.Range("C48:X" & lRow).Copy wb.Worksheets("Receipted")


ActiveSheet.Name = "Receipted"

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I am having problems with the below code
That is pretty vague! Helpers would normally find it much easier to give advice if you tell us: Is it ..
  • Crashing Excel
  • Giving an error message (if so full error message and which line of code?)
  • Copying the wrong data to the right place (details)
  • Copying the right data to the wrong place (details)
  • etc
However, in this case I think that your issue is simply that you are not telling Excel where on 'Receipted' to paste the data.

Something like this
Rich (BB code):
wsData.Range("C48:X" & lRow).Copy wb.Worksheets("Receipted").Range("A1")

BTW, there isn't any advantage in naming 'Receipted' twice. ;)
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,267
Members
448,558
Latest member
aivin

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