Maro to copy data and paste based on cell value

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
Hi Team ,

I have 3 sheets Process, Master & Data
Process sheet Cell “C1” has row number Example:”A2”

My macro should copy data from Master sheet “A4:L200” and paste it in “Data”sheet based on cell value in Process sheet Cell “C1(in current case its Cell A2)

My current code doesn't work-


Worksheets("Master").Range("A4:L200").Copy
Worksheets("Data").Range(WB.Sheets("Process").Range("C1").Value).PasteSpecial Paste:=xlPasteValues

Thanks
chan
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try:

Code:
Worksheets("Data").Range(WB.Sheets("Process").Range(Range("C1").Value)).PasteSpecial paste:=xlPasteValues
 
Upvote 0
What is WB?
Also what does "doesn't work" mean?, do you get any errors, does nothing happen, does it paste the data to the wrong?
 
Upvote 0
Can you please answer my other question as well, namely "What is WB"? Have you declared it anywhere?, have you given it a value?

Assuming all sheets are in the same workbook then just remove it.
 
Last edited:
Upvote 0
Hi Below is the entire code which i am using were i have declared WB as woeksheet

Sub CopyRND()
'
' Chan
'
Dim wS As Workbook
Dim wb As Worksheet
Set wb = wb.Sheets("Process")
'>>>> Copy to Data Sheets
Worksheets("Master").Range("A4:L200").Copy
Worksheets("Data").Range(wb.Sheets("Process").Range(Range("C1").Value)).PasteSpecial Paste:=xlPasteValues
End Sub
 
Upvote 0
As you have declared WB as a worksheet, the code should be
Code:
Worksheets("Data").Range(wb.Range("C1").Value).PasteSpecial Paste:=xlPasteValues
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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