What Ben said. Try something like this...
Note: format cell C7 with any date format you like.
Sub Run_Button()
Dim RowMatch As Variant 'Row number of the matched Auction Number
Dim AuctionNum As Integer 'the auction number
'updates the date with todays date
Range("H2").Value = Date
'prompts the user to enter the auction number then stores it in the variable AuctionNum,
'the value is then placed in cell c6 of the workbook
AuctionNum = Application.InputBox("Please enter the auction number", "Next Auction Data", Type:=1)
If AuctionNum = 0 Then Exit Sub 'User canceled
Range("C6").Value = AuctionNum
'Match Auction Number and return the row number of 1st match
RowMatch = Application.Match(AuctionNum, Sheet2.Range("C:C"), False)
If Not IsError(RowMatch) Then 'Test if match was found
Range("C7").Value = Sheet2.Range("B" & RowMatch).Value 'Return Value from column B of the matched row
Range("C8").Value = Sheet2.Range("D" & RowMatch).Value 'Return Value from column D of the matched row
Range("C9").Value = Application.CountIf(Sheet2.Range("C:C"), AuctionNum) 'Count rows that have the auction number
Else
MsgBox "No match found for " & AuctionNum, , "Auction Number Not Found"
End If
End Sub
Bookmarks