-
Return Value into userform.
Missing something simple here, I know...
Trying to return the value of a cell which is 2 columns right of the cell in Worksheet "Data 2" that contains the same value that is in TextboxQuoteNumber.
[vba]TextBoxSalesman.Value = Sheets("Data 2").Find(TextboxQuoteNumber.Value).Offset(0, 2).Value[/vba]
-
Try
[VBA]TextBoxSalesman.Value = CStr(Sheets("Data 2").Cells.Find(TextboxQuoteNumber.Value).Offset(0, 2).Value)[/VBA]You may have to convert the TextBoxQuoteNumber.Value if the cells contain other than text.
-
Thank you Mike.
I'm still getting an error message. "Object variable or With block variable not set". I set it up With (and without)... but.. continuing to beat myself up.
[VBA] With Sheets("Data 2")
TextboxQuoteNumber.Value = QuoteNo.TextBox_QuoteNo.Value
TextBoxSalesman.Value = CStr(Sheets("Data 2").cells.Find(TextboxQuoteNumber.Value).Offset(0, 2).Value)
End With[/VBA] Thanks for any additional recommendations !
-
The error means the search string wasn't found. I advise you to also use the other agruments of the Find method to prevent it using the wrong settings.
-
That means that the activeworkbook has no sheet named "Data 2".
You will also get an error if there is no cell found.
[VBA] Dim f As Range
With Sheets("Data 2")
TextboxQuoteNumber.Value = QuoteNo.TextBox_QuoteNo.Value
Set f = Sheets("Data 2").Cells.Find(TextboxQuoteNumber.Value)
If f Is Nothing Then Exit Sub
TextBoxSalesman.Value = CStr(f.Offset(0, 2).Value)
End With[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules