Re: find next loop VBA
ok shame...
Code
Private Sub CommandButton1_Click()
Dim wb As String
wb = ActiveWorkbook.Name
Dim Rng1 As Range, c As Range
Dim strAddress As Range
Dim MyVar As String
MyVar = UserForm1.TextBox1.Text
If MyVar = "" Then
MsgBox "Please enter Vendor Number.", vbOKOnly, "Error"
End If
Set Rng1 = Range("A1:T30000") 'I would actually use CurrentRegion or usedRange here
With Rng1
Set c = .Find(what:=MyVar, LookAt:=xlPart, LookIn:=xlValues, SearchDirection:=xlNext)
If Not c Is Nothing Then
Application.ScreenUpdating = False
Workbooks.Add
ActiveWorkbook.SaveAs ("C:\whatever.xls")
Dim p_rw As Integer
p_rw = 2
Windows(wb).Activate
Do Until c Is Nothing Or c.Interior.ColorIndex = 3
c.Interior.ColorIndex = 3 'highlight foun cell, amend action to suit
Range(Cells(c.Row, 1), Cells(c.Row, 26)).Copy
Windows("whatever").Activate
Cells(p_rw, 1).PasteSpecial xlPasteValues
p_rw = p_rw + 1
Windows(wb).Activate
Set c = .FindNext(c)
Loop
Application.ScreenUpdating = True
Else
MsgBox "Cannot Find " & searchtxt.Text & ".", vbOKOnly, "Sorry"
End If
End With
End Sub
Display More
Not particularly clean or watertight but should give you the general idea...