Hi.
This is a part of a big macro (in a module).
Here is the structure of my macro (in module);
I get a RaNge using LastRow; range("A" & LastRow) where LastRow is range("D" & Rows.Count).End(xlUp).Row.
I then launch the userform; userform.Show
In the userform, there is a TextBoX. The input in this TextBoX is a VariaBle.
What I want is to check if this VariaBle is in the RaNge. If it is, then use the VariaBle. IF NOT, then I would like to get a message box that tells me "Try again", and send me back to the userform.
Til now I have tried to do this by doing like this:
Public VariaBle as string (as this can contain both numbers and text, typ. 134A)
In the macro in the module I have as said earlier gotten the RaNge from LastRow.
userform.Show
In the userform I have in the commandbutton: VariaBle=userform.TextBoX
then, back in the module I have:
For Each cell in RaNge
if application.proper(VariaBle)=application.proper(cell) then
sMR=cell.row
end if
next cell
I then discovered that the value of sMR is 0(zero) if the VariaBle is not found in the RaNge, so I wrote strait after the line over;
if sMR=0 then
msgbox "Can't find what you want"
call macro (this is the same macro as I am writing in now)
end if
And then there are lots of codes and calculations.
This method does actually all it sholud (I get all the results I want, even those at the end of the macro), BUT when the macro is done, I get an error (1004, application-defined or object-defined error)????
I hope someone understand what I'm trying to say, and can help me.
By the way, how do I make those nice excel lines into this post?
Thanks!!
Bookmarks