Macro to copy values to worksheets based on value

cjlaing

New Member
Joined
Aug 18, 2017
Messages
10
Hi

I am looking to write a macro where it takes the information from the 1st sheet and copies it out to the appropriate worksheets when I run the macro. I am looking to move them out into worksheets named after contract numbers 8060, 8290, 8483 as examples. There will be a column in the front sheet that states the contract.

Any help would be much appreciated.

Thanks

CJ
 
I had changed it but I had put 6 rather than 5.

The only other thing that isn't working is it isn't copying column A. I tried tweaking the line of code I thought was required to change but that seemed to cause it to copy all the rows into each sheet and still not copy column A.

always the risk when you start modifying code - code should copy from the header row Column A to however many columns in the header row.

Did code copy ok when used in it's original form?

Dave
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
always the risk when you start modifying code - code should copy from the header row Column A to however many columns in the header row.

Did code copy ok when used in it's original form?

Dave

All I had done was move where I saw cells defined as being column B rather than column A, as I assumed one of those was likely the issue. It has never copied column A. It is back to its original form, with the exception of the change made earlier.
 
Upvote 0
All I had done was move where I saw cells defined as being column B rather than column A, as I assumed one of those was likely the issue. It has never copied column A. It is back to its original form, with the exception of the change made earlier.

would be helpful if could see your data - are you able to place copy of your workbook with sample data in a dropbox?

Dave
 
Upvote 0
You did not include the macros but no worries problem should be easy to solve - you have not given column A a Field heading - Add a name & see if values copy across.

Dave.
 
Upvote 0
You did not include the macros but no worries problem should be easy to solve - you have not given column A a Field heading - Add a name & see if values copy across.

Dave.

Ah of course! Thanks for all your help with that Dave!

One last thing... where on the code is it defining where the values are being placed in the new sheets? I wouldn't mind them being further down than A1.
 
Last edited:
Upvote 0
Ah of course! Thanks for all your help with that Dave!

One last thing... where on the code is it defining where the values are being placed in the new sheets? I wouldn't mind them being further down than A1.


No worries - glad we got there.

Change destination cell address shown in RED to place where required.

Rich (BB code):
CopyToRange:=wsNew.Range("A1")

Dave
 
Upvote 0
No worries - glad we got there.

Change destination cell address shown in RED to place where required.

Rich (BB code):
CopyToRange:=wsNew.Range("A1")

Dave

I changed to A3 but it now comes up with "Object variable or With block variable not set".

EDIT: Sorry no - I was at the wrong bit!
 
Last edited:
Upvote 0
I changed to A3 but it now comes up with "Object variable or With block variable not set".

EDIT: Sorry no - I was at the wrong bit!

do you have it working now - if not, post changes you made?

Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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