Copy data from one worksheet to another.

sandor jeges

New Member
Joined
May 26, 2016
Messages
13
Hi,

Not sure if my last post worked or not but:

Sorry for my newbie question but I am trying to write a code to copy data over from one worksheet to another but what is copied over is dependant on certain there being data in firstly column B and then Column D (once the ISEMPTY function completes in column B i want the same criteria to be picked up but from the rule of data being in column D.

My goal is to ask the code to read off column B, if there is a code in column B, then copy to a new worksheet (that i would like to name) from the same row, but only copy a number of columns wihtin the same row. Then move to Column D and do the same. As an example:

Raw data
Column A Column B Column C Column D Column E Column F Column G Value
Type of car Seller Model of car Buyer Make of Car Transmission Date of transaction Purchase price/seller receive

New Worksheet Called "Car Varieties"
Column A Column B Column C Column D Column E Column E Column F
Seller Date of Transactions leave blank Purchase price/seller receive Model of Car leave blank Transaction reference*
Buyer Date of Transactions leave blank Purchase price/seller receive Model of Car leave blank Transaction reference*

Off course the above is just an example, in truth i have a number of lines.

*The transaction reference would be a mix of the result of Column B&Column A&Column E

I have only be able to create it so my code copies and paste the whole row which is not what i want - please help!
Cheers
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
From my reading here is the main question:

My goal is to ask the code to read off column B, if there is a code in column B, then copy to a new worksheet (that i would like to name) from the same row, but only copy a number of columns wihtin the same row. Then move to Column D and do the same. As an example:

Question:
1.What is a code? Do mean a value?
and if "George" is in column "B" copy this row to a sheet named "George" is that what you want?
And has the sheet named "George" already been created or do we need to create this new sheet?

The you say:
but only copy a number of columns wihtin the same row.
What columns I do not understand which columns.

And then if "Bob" is in column "C" copy this same row to a sheet named "Bob"

And on and on for how many columns in this same row.

Is this what you want?

If so we need more details:

We need sheet names and column numbers
 
Upvote 0
Sorry for the confusion. Ill answer your question first - I did mean values (not codes) for Column B & D

Ill give more information:
My Macro should have 3 tabs
1. A button to run the macro
2. the raw data copied and pasted from another source - Ill call it "Raw Data"
3. the data changed in the order i suggested - called Output

I am hoping to have the macro read all rows in the worksheet "raw data". Say that there are 100 rows. I only want certain columns to be copied over to the "Output" Tab
So my end result should be 200 rows in the "Output" tab with only the values off that row for only a select number of columns which i detemine...

is that possible?

[TABLE="width: 2571"]
<tbody>[TR]
[TD="class: xl66, width: 81"]
any help would be awesome![/TD]
[TD="class: xl66, width: 90"][/TD]
[TD="class: xl66, width: 73"][/TD]
[TD="class: xl66, width: 88"][/TD]
[TD="class: xl66, width: 78"][/TD]
[TD="class: xl66, width: 110"][/TD]
[TD="class: xl67, width: 188"][/TD]
[TD="class: xl66, width: 60"][/TD]
[TD="class: xl66, width: 112"][/TD]
[TD="class: xl68, width: 142"][/TD]
[TD="class: xl66, width: 68"][/TD]
[TD="class: xl66, width: 68"][/TD]
[TD="class: xl66, width: 340"] [/TD]
[TD="class: xl66, width: 143"]Short Name [/TD]
[TD="class: xl66, width: 50"]CRY[/TD]
[TD="class: xl69, width: 92"]SEDOL code [/TD]
[TD="class: xl66, width: 94"]ISIN code [/TD]
[TD="class: xl68, width: 134"]Historical Cost (B)[/TD]
[TD="class: xl66, width: 104"]Market Price[/TD]
[TD="class: xl67, width: 122"]Exch Ntv to Base[/TD]
[TD="class: xl68, width: 132"]Market Value (B)[/TD]
[TD="class: xl68, width: 134"]Market Value (N)[/TD]
[TD="class: xl70, width: 68"][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Further to my last note, i stated 200 rows to be populated in the "Output" tab as I want the macro to populate rows contingent on values being found in Column B THEN do the same for column D. Hope that makes sense :)
 
Upvote 0
I should also state, I did find this code that hopefully is putting me in the right direction - but it only copies that whole row rather than only a select number of columns instead...

Set I = Sheets("Employee Inventory")
Set e = Sheets("EEs")
Dim d
Dim j
d = 1
j = 2

Do Until IsEmpty(i.Range("Q" & j))

If i.Range("Q" & j) = "TERM" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value

End If
j = j + 1
Loop
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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