code to dis[play a message if the active cell contains an asteric

T

Tonso

i haved a macro that allows a user to enter in an input bax a number
that will multiply the value in the cell. i would like to have a
message box appear if the macro is invoked and the cell has an asteric
in it. How can i accomplish this? Basically, if one of the characters
in the cell in an asteric, the a messagebox would state something to
that effect. I know how to do a messagebox, what i dont know is the
"if there is an asteric" part.

thanks,

Tonso
 
D

Don Guillett

i haved a macro that allows a user to enter in an input bax a number
that will multiply the value in the cell. i would like to have a
message box appear if the macro is invoked and the cell has an asteric
in it. How can i accomplish this? Basically, if one of the characters
in the cell in an asteric, the a messagebox would state something to
that effect.  I know how to do a messagebox, what i dont know is the
"if there is an asteric" part.

thanks,

Tonso

If the intent is to change the multiplier, this macro will do it for
something like
=a1*2
to change it to =a1*5
adapt to suit

Sub changemultiplier()
For Each c In Cells.SpecialCells(xlCellTypeFormulas)
x = InStr(c.Formula, "*")
If x > 0 Then
c.Formula = Left(c.Formula, x) & "5" & Mid(c.Formula, x + 2, 256)
Next c
End Sub
 
G

Gloops

Tonso wrote, on 27th Feb. 2012 20:01 UTC + 1 :
i haved a macro that allows a user to enter in an input bax a number
that will multiply the value in the cell. i would like to have a
message box appear if the macro is invoked and the cell has an asteric
in it. How can i accomplish this? Basically, if one of the characters
in the cell in an asteric, the a messagebox would state something to
that effect. I know how to do a messagebox, what i dont know is the
"if there is an asteric" part.

thanks,

Tonso


Hello,

It seems Don Guillett told what to do.
About where to do it ...
The messagebox will be validated independently from what there is in it.
Your treatment would arrive after the messagebox, and if needed you have
to open another.

If you want to avoid to close the messagebox if the contents is not
validated, presumably you have to write a userform, and only validate it
when the contents is OK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top