If.......THEN help please

fry

Active Member
Joined
Apr 25, 2007
Messages
411
Hi Guys

A small problem with if.......then but I can't work out how to do it...

I have a user inputted variable 'ipt' that could be a number or text.

If its a number I want to add 'C20' to it (eg 480 becomes C20480), but if its text I want to leave it as it is.

I can happily add the 'C20' bit but I'm not sure how to check if its text so in my words I'd like to do the following

If ipt = 'a number' then ActiveCell.FormulaR1C1 = "C20" + ipt

I just dont know what the 'a number' syntax would be in VBA

All help, great or small is much appreciated :)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
PERFICK!!!!!

Thanks for your help.........ain't it easy when you know what you're doing!! :)

I don't suppose there is an easy way to change the users inputted text from lower case to upper case is there??? :):)
 
Upvote 0
Code:
If IsNumeric(ipt) Then

ipt = "C20" & ipt
Else

ipt = LCase(ipt)
End If
 
Upvote 0
Hi Andrew and xld

Sorry I should have been more specific :(

What I have is
Code:
If wsCur.Range("L6") = ipt then

which means that if the user puts in for example 'spoh' in lower case nothing will happen because the value in the cell will be 'SPOH'. I couldn't work out how to do....

If L6 = ipt (or ipt in upper case) then......

hope thats a bit clearer???? :)
 
Upvote 0
Yep, just like that.................perfick again!!!

A 1000 thanks to you and all for your help

You've made an old git happy :)
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top