Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hi, very new to VB code, I just found a code online and was trying to convert it to work as I want. Pretty much, as you can see in the code below, I want the cell to say Hi, if the referenced cell has a 1 in it. But when I try it in excel, i get a #VALUE! error. if I put in a 2, I do get the correct return, and putting in anything else gets a 0, as it supposed to. But how do I get text to return in the cell? I tried changing cell format to text, but that didnt work.
And I need to use VB because I will end up having more than 7 IF statements, which I found out, is the most excel can handle. Thanks. Function CalcValue(pVal As String) As Long Select Case pVal Case "1" CalcValue = "hi" Case "2" CalcValue = 64 Case Else CalcValue = 0 End Select End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text format - setting text colour with code | Excel Discussion (Misc queries) | |||
Need to Add Text to Control Text Box via Command Button code | Excel Programming | |||
Macro - Fixed text code needs replacing with variable text | Excel Discussion (Misc queries) | |||
Code for searching & copying Text from 1 text file to another | Excel Programming | |||
Convert a Number Code to a Text Code | Excel Discussion (Misc queries) |