help statement unfinished

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've come up with this formula so far, but it needs to make a loop,I think
with an If statement. Also the string to be found is always in column A. I
didn't put it in there yet. Anyone?


Cells.Find(What:="[bestandnaam*", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Selection.Offset(1, 5).Select
ActiveSheet.Paste
 
Will this work for you? I removed the bracket ([) and replaced it
with a single character wild card.
Sub this()
For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "A").Text Like "?bestandnaam*" Then
Range(Cells(i, "A"), Cells(i, "A").End(xlToRight)).Cut _
Destination:=Cells(i, "A").Offset(1, 5)
End If
Next i
End Sub
 
Sub ABCD()
Range("a1").Select
Do
Set rng = Columns(1).Find(What:="[bestandnaam*", _
After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rng Is Nothing Then
rng.Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Selection.Offset(1, 5).Select
ActiveSheet.Paste
Else
Debug.Print "not found"
End If
Cells(ActiveCell.Row, 1).Select
Loop Until rng Is Nothing

End Sub
 
Thanks! They both work very well for me!


Tom Ogilvy said:
Sub ABCD()
Range("a1").Select
Do
Set rng = Columns(1).Find(What:="[bestandnaam*", _
After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rng Is Nothing Then
rng.Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Selection.Offset(1, 5).Select
ActiveSheet.Paste
Else
Debug.Print "not found"
End If
Cells(ActiveCell.Row, 1).Select
Loop Until rng Is Nothing

End Sub
--
Regards,
Tom Ogilvy


Jootje said:
Hi,

I've come up with this formula so far, but it needs to make a loop,I think
with an If statement. Also the string to be found is always in column A. I
didn't put it in there yet. Anyone?


Cells.Find(What:="[bestandnaam*", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Selection.Offset(1, 5).Select
ActiveSheet.Paste
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top