SOLVED

select text from a file

Copper Contributor

dear friends 

I work excel files where the column B is a text  this text repeat several columns down 

question how to select the firsts two names om column b and copy and paste on another file 

this is the sample 

in other words i want to get the first two ABT and paste on another file and so on  and so on with the next names 

thank you in advance 

best regards 

edu1102 

2012-01-31ABT21.0062
2012-08-17ABT26.0049
2012-10-17ABT28.0035
2012-11-01ABT26.0063
2012-12-17ABT26.0048
2012-01-03ACN44.0069
2012-02-08ACN47.0043
2012-06-27ACN47.0055
2012-12-20ACN58.0037
2012-12-27ACN56.0053
2012-08-24ADBE32.0043
2012-08-29ADBE32.0055
2012-08-31ADBE31.0055
2012-02-23ADI31.0051
2012-03-14ADI31.0044
2012-04-02ADI31.0031
2012-08-22ADI31.0048
2012-01-10ADM22.0037
2012-01-17ADM22.0043
2012-01-31ADM22.0037
2012-06-19ADM23.0043
2012-08-10ADM20.0055
2012-10-31ADM21.0061
2012-11-05ADM20.0064
2012-02-07ADP38.0048
2012-02-09ADP37.0055
2012-05-02ADP38.0052
2012-09-12ADP40.0033
    
2 Replies
best response confirmed by Hans Vogelaar (MVP)
Solution

@edu1102 

Sub selectrows()

Dim i As Long
Dim j As Long
Dim k As Long
Dim m As Long
Dim n As Long

Range("F:I").Clear
m = 2
i = Range("A" & Rows.Count).End(xlUp).Row

For j = 2 To i

n = Application.WorksheetFunction.CountIf(Range(Cells(2, 2), Cells(j, 2)), Cells(j, 2))

If n = 1 Then

Range(Cells(j, 1), Cells(j + 1, 4)).Copy Destination:=Cells(m, 6)
m = m + 2

Else

End If

Next j

End Sub

Maybe with these lines of code. In the attached file you can click the button in cell K2 to run the macro.

select rows.JPG

@OliverScheurich 

My Friend thank you for your help 

Iwill credit you on this work

If you need anyhthing that i can help you 

I will be at your service 

best of the best 

eduardo 

1 best response

Accepted Solutions
best response confirmed by Hans Vogelaar (MVP)
Solution

@edu1102 

Sub selectrows()

Dim i As Long
Dim j As Long
Dim k As Long
Dim m As Long
Dim n As Long

Range("F:I").Clear
m = 2
i = Range("A" & Rows.Count).End(xlUp).Row

For j = 2 To i

n = Application.WorksheetFunction.CountIf(Range(Cells(2, 2), Cells(j, 2)), Cells(j, 2))

If n = 1 Then

Range(Cells(j, 1), Cells(j + 1, 4)).Copy Destination:=Cells(m, 6)
m = m + 2

Else

End If

Next j

End Sub

Maybe with these lines of code. In the attached file you can click the button in cell K2 to run the macro.

select rows.JPG

View solution in original post