Copy and Paste Row from sheet to sheet if Cells Match

Celticshadow

Active Member
Joined
Aug 16, 2010
Messages
414
Office Version
  1. 365
Platform
  1. Windows
Hi Forum

Would forum be kind enough to try and provide a solution for my formula problem in copying a row from one sheet to another dependent on a cell value matching.

I have two sheets one named Btn Fav and the other named Odds Tracker 1, if the cell I2 (containing horse name) in the Btn Fav sheet matches a cell in column B in the odds tracker sheet then I would like to copy the row from A to Q and paste it into the Btn Fav sheet starting at Col P through to Col AF. I have attached an example of what I would like to do as example. Many thanks for looking and hopefully providing a solution.

Regards
 

Attachments

  • Btn Fav sheet.png
    Btn Fav sheet.png
    34.9 KB · Views: 14
  • Odds Tracker sheet.png
    Odds Tracker sheet.png
    33.8 KB · Views: 14

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hey, I'm not totally sure where the data to the left of your blue arrow is coming from, but I have a formula that seems to do what you want?

Paste below in cell P2:
=FILTER('Odds Tracker 1'!A2:Q12,'Odds Tracker 1'!B2:B12=I2)

You can make a dropdown of the various horse names as a list in the cell you pointed out with the blue arrow, and the formula above will copy all data for the horse you select.
 
Upvote 0
Hey, I'm not totally sure where the data to the left of your blue arrow is coming from, but I have a formula that seems to do what you want?

Paste below in cell P2:


You can make a dropdown of the various horse names as a list in the cell you pointed out with the blue arrow, and the formula above will copy all data for the horse you select.
Hi TheMacroNoob

Many thanks for replying it is much appreciated. I have put your above formula into my sheet but it returns a #value! in the cell so I am not sure what I am doing wrong unless it has something to do with formatting.

Regards
 
Upvote 0
Hi TheMacroNoob

Many thanks for replying it is much appreciated. I have put your above formula into my sheet but it returns a #value! in the cell so I am not sure what I am doing wrong unless it has something to do with formatting.

Regards

Do you have the FILTER() function? When you start typing it in? If you do, then your sheet names might be slightly different?

See below for my cells and formulas: I added an index to the rows after the first if you preferred no spill array. Otherwise the formula should work if you have the correct cell references and sheet names


MrExcelHelp.xlsx
ABCDEFGHIPQRSTUVWXYZAAABACADAEAF
1DateTimeTrackRace TypeDistanceClsRunNoHorseNoHorseJockeyTrainerLRFCEARLY0.380.420.470.510.53Live ShowNOWWIN %Move %Pos
2Luigi47Luigi816350668120845272386385458811
3Princess25Princess417966666403288782738131743
4Gin Coco1Gin CocoBurke, JonathanFry, Harry2of25 1L 4.332.631.291.441.291.291.291.441.40 1.36 1.33 1.36 1.331.3375.00%13.79%1st
Btn Fav Sheet
Cell Formulas
RangeFormula
P2:AF2P2=FILTER('Odds Tracker 1'!$A$2:$Q$12,'Odds Tracker 1'!$B$2:$B$12=$I2)
P3:AF4P3=INDEX(FILTER('Odds Tracker 1'!$A$2:$Q$12,'Odds Tracker 1'!$B$2:$B$12=$I3),COLUMNS($A$1:A$1))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
I2:I4List='Odds Tracker 1'!$B$2:$B$12


Test Sheet:
MrExcelHelp.xlsx
ABCDEFGHIJKLMNOPQ
1NoHorseJockeyTrainerLRFCEARLY0.380.420.470.510.53Live ShowNOWWIN %Move %Pos
21Gin CocoBurke, JonathanFry, Harry2of25 1L 4.332.631.291.441.291.291.291.441.40 1.36 1.33 1.36 1.331.330.750.13791st
310Potato507423174364818817447247224740
420Horsey301755562418356664712351642947
570Wowzers695785873846815840853193215593
689Mario38345697441612310201791430
747Luigi816350668120845272386385458811
825Princess417966666403288782738131743
974Omega5576244275798171001935782271100
1033Delta55932104210768721514372184323
1187Number0613015475424917229494919273
1229Manes6451375051932636976980100472743
13
14
15
Odds Tracker 1
 
Upvote 0
Hi TheMacroNoob

Yes I do have the macro filter and the sheet names are correct so I am at a loss, although not having the knowledge that yourself and forum members have will more than likely mean I am missing something.

Regards
 
Upvote 0
Two alternatives in addition to the first formula (If you don't have FILTER():
MrExcelHelp.xlsx
HIPQRSTUVWXYZAAABACADAEAFAG
1NoHorseNoHorseJockeyTrainerLRFCEARLY0.380.420.470.510.53Live ShowNOWWIN %Move %Pos
2Gin Coco1Gin CocoBurke, JonathanFry, Harry2of25 1L 4.332.631.291.441.291.291.291.441.40 1.36 1.33 1.36 1.331.3375%13.79%1st
3
4
5Gin Coco1Gin CocoBurke, JonathanFry, Harry2of25 1L 4.332.631.291.441.291.291.291.441.40 1.36 1.33 1.36 1.331.3375%13.79%1st
6
7
8Gin Coco1Gin CocoBurke, JonathanFry, Harry2of25 1L 4.332.631.291.441.291.291.291.441.40 1.36 1.33 1.36 1.331.3375%13.79%1st
9
10
11
Btn Fav Sheet
Cell Formulas
RangeFormula
P2:AF2P2=FILTER('Odds Tracker 1'!$A$2:$Q$12,'Odds Tracker 1'!$B$2:$B$12=$I2)
P5:AF5P5=INDEX('Odds Tracker 1'!$A$2:$Q$12,MATCH($I5,'Odds Tracker 1'!$B$2:$B$12,0),0)
P8:AF8P8=XLOOKUP($I8,'Odds Tracker 1'!B2:B12,'Odds Tracker 1'!A2:Q12)
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
I2:I5List='Odds Tracker 1'!$B$2:$B$12
I8List='Odds Tracker 1'!$B$2:$B$12
 
Upvote 0
Hi TheMacroNoob

Yes I do have the macro filter and the sheet names are correct so I am at a loss, although not having the knowledge that yourself and forum members have will more than likely mean I am missing something.

Regards

Hmm, if you have =FILTER() and it shows as you type, then the cell references need to be checked, the sheet names, or you have a typo in the horse name cell (i2).

Is there any way for you to post your sheet as it stands?
 
Upvote 0
Hi TheMacroNoob

Is it ok to post to google docs as I have tried to post a table before but I was unable to thats why I put up images?

Regards
 
Upvote 0
Hmm, if you have =FILTER() and it shows as you type, then the cell references need to be checked, the sheet names, or you have a typo in the horse name cell (i2).

Is there any way for you to post your sheet as it stands?
Hi TheMacroNoob

I have attached an image of the Odds Tracker sheet which shows all the days results within it. Thus I think the problem is ( my fault for not posting a complete query I suppose) that I want to search that column B from B2 through to B900 in the Odds Tracker sheet for the horse in the Btn Fav sheet and when a match is found then copy that row over. Hope that makes sense.

Regards
 

Attachments

  • Btn Fav sheet query 2.png
    Btn Fav sheet query 2.png
    53.8 KB · Views: 7
  • Odds Tracker Query 2.png
    Odds Tracker Query 2.png
    65.9 KB · Views: 7
Upvote 0
I think it's because I did not absolute reference the formula at the beginning:

=FILTER('Odds Tracker 1'!$A$2:$Q$12,'Odds Tracker 1'!$B$2:$B$12=$I2)

You can either copy the formula above and see if that works once you drag the autofill down, or press F4 on your various cell references to absolute reference the ranges on Odds Tracker 1. The criteria, i2, does not need to be changed. Apologies for the confusion, I thought you were getting an error on everything!
 
Upvote 0
Solution

Forum statistics

Threads
1,214,788
Messages
6,121,600
Members
449,038
Latest member
Arbind kumar

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