I am new to the forums, and really new to VBA in excel. I have found some code to search for a text string, and I tried to adapt it to search through sheets in a workbook for a string "Logs" and then copy the cell 2 columns to the right. Then I am trying to paste the hyperlink at the end of the row entry on the master sheet in the workbook "6N656667". This is pretty ambitious code for me, and I'm not even proficient enough at debugging it to figure out where my mistake is. The code is as follows:
Sub lookforlas()
'For i=3 to 2420
For x = 3 To x = 103
yy = 24
'mystr is the name of the sheet we are searching for logs
Worksheets("5N656667").Select
Worksheets("5N656667").Activate
mystr = "Cells(x, 4)"
Dim fnd As String, FirstFound As String
Dim FoundCell As Range, rng As Range
Dim myRange As Range, LastCell As Range
'What value do you want to find (must be in string form)?
fnd = "*Log*"
Set myRange = Worksheets(mystr).UsedRange
Set LastCell = myRange.Cells(myRange.Cells.Count)
Set FoundCell = myRange.Find(what:=fnd, after:=LastCell)
'Test to see if anything was found
If Not FoundCell Is Nothing Then
FirstFound = FoundCell.Address
Else
GoTo NothingFound
End If
Set rng = FoundCell
Cells(FoundCell.Row, 6).Copy
Worksheets("5N656667").Cells(x, yy).PasteSpecial Paste:=xlPasteAll
yy = yy + 1
'Loop until cycled through all unique finds
Do Until FoundCell Is Nothing
'Find next cell with fnd value
Set FoundCell = myRange.FindNext(after:=FoundCell)
'Test to see if cycled through to first found cell
If FoundCell.Address = FirstFound Then Exit Do
Loop
Exit Sub
'Error Handler
NothingFound:
Worksheets("5N656667").Cells(x, 24).Value = "No Logs Found"
Next x
End Sub
Sub lookforlas()
'For i=3 to 2420
For x = 3 To x = 103
yy = 24
'mystr is the name of the sheet we are searching for logs
Worksheets("5N656667").Select
Worksheets("5N656667").Activate
mystr = "Cells(x, 4)"
Dim fnd As String, FirstFound As String
Dim FoundCell As Range, rng As Range
Dim myRange As Range, LastCell As Range
'What value do you want to find (must be in string form)?
fnd = "*Log*"
Set myRange = Worksheets(mystr).UsedRange
Set LastCell = myRange.Cells(myRange.Cells.Count)
Set FoundCell = myRange.Find(what:=fnd, after:=LastCell)
'Test to see if anything was found
If Not FoundCell Is Nothing Then
FirstFound = FoundCell.Address
Else
GoTo NothingFound
End If
Set rng = FoundCell
Cells(FoundCell.Row, 6).Copy
Worksheets("5N656667").Cells(x, yy).PasteSpecial Paste:=xlPasteAll
yy = yy + 1
'Loop until cycled through all unique finds
Do Until FoundCell Is Nothing
'Find next cell with fnd value
Set FoundCell = myRange.FindNext(after:=FoundCell)
'Test to see if cycled through to first found cell
If FoundCell.Address = FirstFound Then Exit Do
Loop
Exit Sub
'Error Handler
NothingFound:
Worksheets("5N656667").Cells(x, 24).Value = "No Logs Found"
Next x
End Sub