Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying and pasting data from 2 columns of different lengths

Status
Not open for further replies.

lioyeo

Technical User
Jul 14, 2010
2
GB
Hi, any help on vba code or formula for the following problem would be greatly appreciated:

Part 1:
I have 2 sets of data on the same worksheet, but the data corresponds to columns of different lengths. For example, Column E has more dates and more data than Column B. If the date in Column E matches the date in Column B, I'd like the corresponding data in the cell to the right of the date (Column C) to be pasted in Column F, next to the matching date in Column E.

Part 2:
Next, looking at just Column F, I'd like to copy the data from one cell into all the blank spaces below it, until a cell with new data is reached. I want to do the same for the new data as well.

I hope my explanation was clear enough! Please see my attachment for clarification. This would greatly help in a project I'm doing and I have over 5000 rows to work with, simply not feasible to do it by hand.

Thanks in advance :)
 


Hi,

Seems to me that BOTH of your requirements can be simply done ON THE SHEET...

If the date in Column E matches the date in Column B, I'd like the corresponding data in the cell to the right of the date (Column C) to be pasted in Column F, next to the matching date in Column E.
[tt]
F2: =if(E2=B2,C2,"")
[/tt]
Next, looking at just Column F, I'd like to copy the data from one cell into all the blank spaces below it, until a cell with new data is reached. I want to do the same for the new data as well.
[tt]
F2: =if(E2=B2,C2,F1)
[/tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi, that wasn't exactly what I was looking for as the rows may not align in the 2 columns, but I asked a friend and found that it can be solved with a VLOOKUP and an IF function, ie
VLOOKUP(D3,$A$2:$B$51,2,FALSE)in one column and
IF(ISERROR(E3),F2,E3) in another column.

Thanks anyway!
 
I think skip's way is better as you wont have the datamismatch problem that your isERROR fixes.

But its all in your conveniance.

"Knowing that you know is the greatest sign of stupidity, knowing that you are ignorant is the best proof of intelligence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top