Search row for defined text and if present, copy and paste it in same row and empty column [closed]

StackOverflow https://stackoverflow.com/questions/21311962

Pregunta

I have delimited text of contact information all separated into different cells from a text import of a PDF document. It's 800 pages and all I want are the lines that contain data from certain states. ie. FL, VA & NC. I want each line to be searched and if any of these three values are present, then in column A, same line, copy and paste it there so I can sort only these three States' contact information to the top for editing.

Transfer clarification provided in comment:

Including the empty column A I've created to paste the state into, the data range is from B to P. The state codes will be guaranteed to be in their own cell but not in the same column. I can do one state at a time so the first formula written in A1 I need would ask it to search all cells to the right and if a cell contains FL then tell me here in cell A1 somehow.. Then I copy that formula all the way down column A pulling out all the lines that pertain to that state

and Change in requirement

Ok... need the formula to do one more thing. Right now, if it reads the text, FL, to the right, it puts a number in column A corresponding to how many cells over it is. ie. If the FL is in column C it puts a 2 in Column A same row. If it's in column E, it puts a 4. So the sorting issue I have now is that the name of the contact and it's street address is in the line immediately before the line with the state and I need that line identified for sorting purposes as well. So the line with the address and the one with the state would have to have a unique value so they would sort together.

¿Fue útil?

Solución

You could perhaps use something like that (I broke it down to several lines since otherwise it's quite long):

=IFERROR(INDEX(B1:P1,1,
  IFERROR(MATCH("VA",B1:P1,0),0)+
  IFERROR(MATCH("NC",B1:P1,0),0)+
  IFERROR(MATCH("FL",B1:P1,0),0)
 )&":"&ROW(),IF(A2=A3,"N/A",A2))

[This function starts on row 1. Change the ranges to B2:P2 if your data starts on row 2, and A2 to A3]

The result of this function would be SS:N where SS represents the state and N represents a unique ID, which will correspond to the row number the state was found in. I'm assuming that rows alternate between name and address, and then the line with the state information.

Upon sorting, you'll have all the lines sorted first by state, then by the unique number.

Otros consejos

For one State at a time something like =MATCH("FL",B1:P1,0) should serve, copied down to suit.

To deal with all three States at once I suggest:

=IF(ISERROR(MATCH("FL",B2:P2,0)),0,1)+IF(ISERROR(MATCH("VA",B2:P2,0)),0,3)+IF(ISERROR(MATCH("NC",B2:P2,0)),0,5)  

with the values representing the possible combinations.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top