aburamewolf
Technical User
Hi I'm new to VBA, I've been trying to fix the error I'm getting when creating a user form in excel, but I'm kind of stuck, the code is presented below.
What the macro should do is, once I click on inotes.text it should automatically use the "ifind" variable to search through the sheet for the account number typed on ian.text and with this obtain the row number of where the account number is.
Once I have the row number, I know if it's already listed or not, if it's listed it should pull the notes that were typed in for that customer number and create two line breaks and a time stamp on inotes.text
if not then it should time stamp inotes.text.
however it keeps coming with an run time
"error '91':
Object variable or With block variable not set"
Could someone help me see where my mistake is?
Thanks in advance!
Here's the code I have so far:
Private Sub inotes_Enter()
Sheets("inbound").Activate
ActiveCell = Cells(1, 1)
Dim timestamp As Variant
Dim x1 As Variant
Dim ifind As Variant
timestamp = Format(Now, "mmm ddd dd yyyy hh:mm:ss AM/PM")
If ian.Text <> "" Then
ifind = Cells.find(what:=ian.Text, after:=ActiveCell)
If IsEmpty(ifind) = True Then
ifind = 1
inotes = timestamp + ""
Else
ifind = Cells.find(what:=ian.Text, after:=ActiveCell).Row
inotes = Cells(ifind, 10) + (Chr(10)) + (Chr(10)) + timestamp
End If
End If
End Sub
What the macro should do is, once I click on inotes.text it should automatically use the "ifind" variable to search through the sheet for the account number typed on ian.text and with this obtain the row number of where the account number is.
Once I have the row number, I know if it's already listed or not, if it's listed it should pull the notes that were typed in for that customer number and create two line breaks and a time stamp on inotes.text
if not then it should time stamp inotes.text.
however it keeps coming with an run time
"error '91':
Object variable or With block variable not set"
Could someone help me see where my mistake is?
Thanks in advance!
Here's the code I have so far:
Private Sub inotes_Enter()
Sheets("inbound").Activate
ActiveCell = Cells(1, 1)
Dim timestamp As Variant
Dim x1 As Variant
Dim ifind As Variant
timestamp = Format(Now, "mmm ddd dd yyyy hh:mm:ss AM/PM")
If ian.Text <> "" Then
ifind = Cells.find(what:=ian.Text, after:=ActiveCell)
If IsEmpty(ifind) = True Then
ifind = 1
inotes = timestamp + ""
Else
ifind = Cells.find(what:=ian.Text, after:=ActiveCell).Row
inotes = Cells(ifind, 10) + (Chr(10)) + (Chr(10)) + timestamp
End If
End If
End Sub