H
Howard
Code does not work and does not error.
Find a value in the Sheets("Sheet1").Range("A1:H11") and copy the values in columns I and K of the "found string" row to Workbooks("Book2").Sheets("Sheet1") Range("B15") and Range("D15") with next copies below the last.
Also, I know there is a cleaner way than the .Range("B100").End(xlUp).Offset(1, 0)
but I cannot find one in my archives.
Thanks,
Howard
Option Explicit
Sub Find_First()
Dim FindString As String
Dim Rng As Range
Dim i As Long
Dim RngI As String
Dim RngK As String
FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
With Sheets("Sheet1").Range("A1:H11")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
i = Rng.Column
RngI = ActiveCell.Offset(0, 9 - i)
RngK = ActiveCell.Offset(0, 11 - i)
Workbooks("Book2").Sheets("Sheet1").Range("B100").End(xlUp).Offset(1, 0) = RngI
Workbooks("Book2").Sheets("Sheet1").Range("D100").End(xlUp).Offset(1, 0) = RngK
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub
Find a value in the Sheets("Sheet1").Range("A1:H11") and copy the values in columns I and K of the "found string" row to Workbooks("Book2").Sheets("Sheet1") Range("B15") and Range("D15") with next copies below the last.
Also, I know there is a cleaner way than the .Range("B100").End(xlUp).Offset(1, 0)
but I cannot find one in my archives.
Thanks,
Howard
Option Explicit
Sub Find_First()
Dim FindString As String
Dim Rng As Range
Dim i As Long
Dim RngI As String
Dim RngK As String
FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
With Sheets("Sheet1").Range("A1:H11")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
i = Rng.Column
RngI = ActiveCell.Offset(0, 9 - i)
RngK = ActiveCell.Offset(0, 11 - i)
Workbooks("Book2").Sheets("Sheet1").Range("B100").End(xlUp).Offset(1, 0) = RngI
Workbooks("Book2").Sheets("Sheet1").Range("D100").End(xlUp).Offset(1, 0) = RngK
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub