Return text NOT date format

So... I have this line of code:

If Range("I" & b) > 0 Then
    Range("V" & b).Value = Range("H" & b) & "-" & Range("I" & b)  ' saw lu key
    Else
    Range("V" & b).Value = "0-0"

It it is concatenating together two numbers with a dash between them.  Problem I have is that when the leading number is 1-12 it comes over formatted as a date.  So if the two numbers I am putting together are 12 and 1 the result is "1-Dec" NOT "12-1".  How do I get it to format to 12-1 not a date of 1-Dec??
deskchainsAsked:
Who is Participating?
 
Rory ArchibaldCommented:
You can just prefix with an apostrophe:

Range("V" & b).Value = "'" & Range("H" & b) & "-" & Range("I" & b)  ' saw lu key

Open in new window


or format the cell as text:

With Range("V" & b)
.numberformat = "@"
.Value = Range("H" & b) & "-" & Range("I" & b)  ' saw lu key
end with

Open in new window

0
 
Rob HensonFinance AnalystCommented:
Change:

Range("V" & b).Value = Range("H" & b) & "-" & Range("I" & b)

to

Range("V" & b).Value = Text(Range("H" & b) & "-" & Range("I" & b),"000-000")
0
 
deskchainsAuthor Commented:
Neither met what I needed, and I ended up going another direction.  However any fresh ideas are always welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.