ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validate Entry (https://www.excelbanter.com/excel-programming/392282-validate-entry.html)

Mike H.

Validate Entry
 
After a User has entered data in a spreadsheet, I want to verify that the
data is valid. I assign a variable to the data I want to validate, go to the
table where the valid data resides and try to do a search but I get a message
"Object Variable or with Block Variable Not Set". Here is basically the code
I am using:

Sub Macro2()
Dim acct As Object
Dim searchfound As String
Cells(1, 1).Select
acct = "x"
Cells.Find(What:=acct, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

searchfound = ActiveCell.Value
If searchfound = acct Then
MsgBox ("Found it")
Else
MsgBox ("Did not find it")
End If

End Sub


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com