Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Jayden Brown   on Oct 01 In MS Office Category.

  
Question Answered By: Faizah Khan   on Oct 01

For the Question 1;

I prefer Val() Function

if val(Range("A1").value) = 0 then ' if it consists a text (not a number), val
returns 0
'This is not a number
strNewFileName = Range("A1").value
else
'This is a number
strNewFileName = "Number" & Range("A1").Value
end if

But remember if Range("A1") consists a number  and the number is 0,then the "IF
STRUCTURE" will act like that it is a text. I mean it won't make strNewFileName
= "Number 0". You can make a little special solution for this. For example you
can control it like this:

if val(Range("A1").value) = 0 and not Range("A1").text = "0"
strNewFileName = Range("A1").value
else
strNewFileName = "Number" & Range("A1").Value
end if

So it fixes the 0(zero) problem. This If Structure will always put "Number" in
front of it, if the value is a number.

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 


Tagged: