Reputation: 49
New day, new problem. I have received much help, and hope you can help me with this too. Have searched around for solutions to my problem but not found.
Here is my code:
SearchString = "start"
Set aCell = phaseRange.Find(What:=SearchString, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
Set bCell = aCell
ReDim Preserve arrStart(nS)
arrStart(nS) = aCell.Row
nS = nS + 1
Do While ExitLoop = False
Set aCell = phaseRange.FindNext(After:=aCell)
If Not aCell Is Nothing Then
If aCell.Row = bCell.Row Then Exit Do
ReDim Preserve arrStart(nS)
arrStart(nS) = aCell.Row
nS = nS + 1
Else
ExitLoop = True
End If
Loop
Else
End If
And to write it out:
For i = 1 To nS - 1
Sheets("DataSheet").Select
Sheets("raw_list").Rows(arrStart(i)).Copy
Cells(i, 1).Select
ActiveSheet.Paste
Next
As you see, I seek in a column for a String. When I get a result, row number is stored in an array. In the next code snippet, I write out hits in entire rows. Is it possible that instead of taking the entire row, choose which columns in that row you want to copy in a simple way?
Grateful for assistance
Upvotes: 1
Views: 1313
Reputation: 149335
If you already know the Column number and you have the rows in array then try this
Sheets("raw_list").Cells(arrStart(i),5).Copy
This will copy the cell from the 5th Column (Col E) in a specific row.
Upvotes: 1