Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

(80% Discount Ends Soon!)

Overview of Text Functions, Formulas, and Uses in Excel

I'm trying to create a receipt as a separate tab in a workbook. I want to be able to type a reference number into one cell and have all of the information that is associated with that reference # fill into other cells. So that when I put in ref # 1234, the name, address, etc, of the person whose reference # that is will populate into all of the corresponding fields. I have tried vlookup, hlookup, as well as index, and have been unsuccessful. any advice is appreciated!


I was wondering it is a must to use numbers for IF function?

The purpose is to set up a confirmation sheet for verification purpose, in
the following way:

(1) Confirmation cell (e.g. C1): Y/N whereas Y = Yes and N = No

(2) If the C1 = Y, D1 = Unit Price x QTY

But it seems that I have to use numeric values, such as 1 or 0 for C1 and
cannot use Y/N which is more like "human language".

Or any other approach?

Many thanks

I need text returned as result when filtering mutiple cells in a column.

I am playing around with creating a text encryption and decryption tool using mainly MS Excel and a little bit of MS Word. The version is 2003. I plan to use macros to prepare an unencrypted message, and for decoding an encrypted message.

My question at this point is: Is there a function which expands on "Code()". This function converts the 1st letter of a text string to its corresponding numerical value. Is there a way (either a function or some sort of workaround) to return the numerical value of the second letter of the text string (and the third, and the fourth, etc.).

If you are interested, here is the challenge I am working on (if not, you can skip this):

Create a workbook. List out all possible characters, numbered 1 to xxx. This would include uppercase, lowercase, numbers, and punctuation marks. Using the random number generator function, assign each letter a random number. Using the sort function, resort the data so that each letter now has a new randomly generated position in the alphabet. For example, If there are 150 different letter where A=1 a=2, B=3, b=4, etc. after they have been sorted, "A" has an equal chance of now being 1 - 150.

While this is a start, this type of code can easily be broken. So to make it more complicated, we can, from letter to letter. shift which key is used to determine what "A" equals. To creating more keys, we simply create a new worksheet page. and repeat the steps above. I would start with 10 pages of keys.

From there we break down the message letter by letter using the CODE() function. This is why i need to figure out how to look at the second and third position in a text string.

Once we have broken the message down to each letter, it is simply a matter of figuring out a way of choosing which key to use for each letter to encrypt the message. I was thinking of using a password, which only the sender and receiver know, which could help in choosing which key to use for which letter. Therefore, even if someone is able to obtain a copy of the workbook, the message would only make sense with the proper password.

For simplicity, lets say if the password is 5 letters long, use key #5 for the first letter, key #6 for the second letter, key #7 for the third letter, etc. If it is 10 letters long, start with key #10, etc. This way, the exact same message would be encoded (and decoded) differently depending on what the length of the password being used was.

Of course it is easy to make this more complicated, for example, possibly taking each letter in the password, giving it a numerical value multiplying it times 7, and dividing it by the length of the password, then rounding it up or down to get the corresponding key to be used.

If I can get the system this far, there are many things that can be added to further complicate the code. I think the first step would be to add nonsense letters into the code. If everything is one for one, at the very least, you can tell exactly how many characters are in the message. However, if 10 - 50% of the characters listed in the text are nonsense characters, then it is very hard to determine the true length of the message.

Of course, adding additional key pages would complicate the code exponentially.

Anyways, that's where I am at right now. Any help is appreciated.

Dear Excel Forum,
I was trying to use the max function to extract information from a table, however for text cells, that function does not seem to work, please advice.
I am attaching the file for easy reference.

Pio Desousa Proenca

Hi all,

I have 3 columns of numerical data. In my fourth column, I would like to return the minimum value from the 3 previous columns (=min). However, instead of returning the lowest number, I would like it to return the column title (=text) of the lowest number. I haven't been able to locate a function that does this. I'd appreciate any help.

Hi, I'm trying to conjure up the easiest way to have some sort of function that will locate a text from column A in column B, and then return the value that is adjacent to that cell, in column C.


(a) (b) (c) (d)
1) A B 2 =findzor(a1,b:b)
2) B D 4
3) C A 5
4) D C 9

so that the function finds the text in a1 in the b column and returns the value adjacent to the right, which would be 5.

tried using offset and match and it turns out i'm over my head

I am using the insert subtotals function and calculating the sum on an amount and count field.

I then want to take the subtotals visible and copy to another spreadsheet to manipulate further.

However, i'm not seeing the description field since there is no subtotal being performed on that column.

Is there any way to pull the description field text down into the automated subtotal lines (i sorted on the description field before inserting the subtotals.

Thanks for any help....

I have attached a dummy file.

The first tab is INPUT and has the data subtotaled without bringing the desc field down.
The second tab is OUTPUT and has the data displayed the way i want it to come out after bringing the desc field down.

I've got lots of text descriptions inside a number of cells, they all have different text. I need to add a sentence to the end of every one, because the descriptions are different I can't use a simple find and replace to do this as the last word or phrase is different on each one. Is there a way to make this text go at the end of every ells description? (the text to be bolted on the end is the same for all)


I've searched the forum but can only find solutions for summing numbers. I wish to count the number of rows in a column that return anything in a cell (including text) when I use the filter function. Basically, like a COUNTA but only for visible filtered rows. Can anyone assist?


What do I need to do to use the concatenate function to take two cells of data:

A1 = 42
B1 = 13.56

to get this result 42O13.56 ... where O is superscripted to indicate degrees?
I have the basics ...


, but how would I format the "O" to be superscript?

Is there a way to change the colour of a number as a result of a conditional IF statement. Something like this:

IF( C1 > 50, change text colour ("Greater than 50"), "Less than 50")

Result if C1 = 60
Greater than 50
Result if C1 = 20
Less than 50

Hi, I am trying to put twitter handles in a cell. ie. @blah.

When I enter @blah into a cell, excel responds with
That function is not valid

How do I prepare/format a call to allow it to contain text with a leading @ symbol?

I have the following formula (taken from the web) in my spreadsheet which let me know if a cell have bold text or not. But when the cell has 'mingled' text, i.e. only partly bold, he gave a #VALUE error.


Function isBOLD(ByVal cell As Range) As Boolean
    isBOLD = cell.Font.Bold
End Function

My question is: Do someone know how to change this formula, so when a cell has 'mingled' text, the result is 'TRUE' and not #VALUE.
I enclose an example spreadsheet.


A simple problem to describe...
=TEXT(A1,"$#,##0.00;[Red]-$,##0.00") where A1 is a negative number.

The negative value is not shown as red - always black.
The cell containing the formula can be formatted as general, number, text, currency - makes no difference.

Ideas ?
Excel 2003, btw

Hello again,
I am working on a hyperlink function that opens up an outlook 2003 email with the subject line and body text taken from specific cells
I am running into the following limitations

1) subject line would include standard text combined with a value taken from another cell (CONCATENATE function). The current formulat I have only takes the standard text but ignores the rest.

2) When I type too much in the body text cell, the error msg #VALUE appears, any idea on what the character limit is for the body text?

I have attached an example worksheet if that will help

I'm having a problem with the sumif function...I'm using it to calculate averages for NBA teams and it's working fine for all teams except the Boston Celtics. For some reason sumif won't recognize the text "Boston Celtics" as the criteria. Any ideas? Thanks.

This seems like a really silly question to me but I've searched up and down for an answer and can't seem to get it.

A1 contains: $10 / sq ft
B1 contains: 10,000

I'd like C1 to show the product of $10 in A1 multiplied by B1. So it needs to ignore '/ sq ft' in A1.

C1 should then contain: $100,000

Is this not possible or am I just not looking in the right places?

Let me know, thanks!

I am attempting to lookup values from one worksheet and populate a few fields on a different worksheet within the same workbook. Our code is a six digit alpha-numeric code, indexed. I have created a large pivot table, which has all the detailed data I require in worksheet 1. I would like, however, to cross reference and add three columns of demographic information from worksheet 2. I plan to add the three columns one by one.

I tried this VLOOKUP formula: =VLOOKUP(A6,Worksheet2!$A$1:$Q$8867,Worksheet2!$L$2:$L$8867,FALSE)

My results are either #N/A (which I believe to mean that there is not a data match, this is OK) or #REF! (which I know means I messed up somewhere). I have almost 1000 lines of data, so I don't want to type in the six digit code each time for the text lookup.

Suggestions appreciated! Thanks!

Finally found a forum discussing this topic.


1. Can someone confirm what is implied above i.e. there is no VBA method to add help to a UDF?

2. Where does the Definition get displayed? Only in the Function text?

My work around is to allow zeros for all parameters as a valid UDF input and then display help text in the cell.

I create a UDF called aaa_HELP (so that it displays at the top of the list). When called, this UDF displays instructions for the all zeros option and gives instructions for formatting the cell to display help text properly i.e. increase cell width, Wrap text and use a fixed width font like Courier New.

I am compiling a relatively complex sheet with various Bloomberg functions, which are done by concatenate, and would like to document it clearly as well as for bug testing see both result and formula.

Thus I am after a function which will execute a text string as function - without using VBA as other people in my department are supposed to be able to understand it in years to come.

Hence I want to write e.g. Today() into Cell A1 and then write "Execute A1" into B1 so that I have the resulting date.

Then I have
A1 B1
Today() 11.2.2008

I have a column of "numbers" formatted as text. I have about 80,000 of these records that is referencing another sheet. VLOOKUP works properly on some records but is not working on about 1/3 of the records. These numbers are 16 digits long and some of them start with a zero (and often multiple zeros). I can't convert these data to numbers because I will lose the leading zeros and the numbers are too large for excel to perform calculations on so it automatically converts them to scientific notation. From my research, VLOOKUP often doesn't work properly when numbers are formatted as text, but I need them to be formatted as text. Does anybody have any ideas on a workaround for this? If it helps, here is my formula:


ANY help will be GREATLY appreciated. Thank you!

Is there a way to change the "voice" that excel uses with this function ?

Thank you in advance.

Hi -- I need to normalize a bunch of company names. By 'normalize' i mean to remove things like "Ltd", "Inc", "LLP", "LP", "The ", "&", etc. The function needs to ignore case and strip out punctuation.

I tried recording a macro (below), but it cuts out if there are too many rows on the file.

Can anyone help me set something up for this? Thanks.
Selection.Replace What:="The ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
Selection.Replace What:=",", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
Selection.Replace What:=":", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
Selection.Replace What:=";", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
Selection.Replace What:="'", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _

I an using the TEXT function because I want to show a number in a cell
without that number being picked up in SUM functions on the worksheet. I
want the text to display with a dollar sign on the far left of the cell, with
a space for parentheses, and the number on the far right. I'm having trouble
getting the formatting right -- the dollar sign shows up just in front of the

My formula is =TEXT('Sheet2'!F16," _($* #,##0_);_($* (#,##0)")

I thought that the asterisk followed by a space would push the dollar sign
all the way to the left. What is wrong? Thanks!

I'm looking to copy 1000 cells of singular form text into the next column
and make it plural. Is there a function to do that?

Thanks in advance!

Sometimes when I enter a funciton in an excel cell it treats it like text. This happens even when I use the "insert function" option and even after I clear contents. When using the "insert function" option the function box shows the correct value but then I hit 'enter' and my cell displays the function text and not the result.

This happens when I have exported data from Access or SAP or some other source into excel. It does not happen every time but does happen fairly often as in now... and I'm frustrated!

Hello everybody,

I'm using Excel 2003 and like to write a VBA function which creates a textbox and fill it with some text.

My function looks like this (just the code which is relevant for the creation of the textbox):


Function CreateBox()
   Dim wsActive As Worksheet
   Dim box As Shape

   Set wsActive = ActiveSheet
   Set box = wsActive.Shapes.AddTextbox(msoTextOrientationHorizontal, 1, 1, 100, 10)
   box.TextFrame.Characters.Text = "test"

End Function

When I execute this function from a cell (e.g. A1 = "=CreateBox()") the textbox is created but no text is visible.

After some time I found out that if I copy the code to a Sub() it works fine:

Sub testsub()

   Dim wsActive As Worksheet
   Dim box As Shape

   Set wsActive = ActiveSheet
   Set box = wsActive.Shapes.AddTextbox(msoTextOrientationHorizontal, 1, 1, 100, 10)
   box.TextFrame.Characters.Text = "test"

End Sub

BUT it doesen't work if I call this Sub from a function:


Function testFunct()
   Call testsub()
End Function

What am I doing wrong?


I'm using an IF function that replaces [square brackets] with "double quotes" (it has to be double quotes)

How do I specify that the double quote character is inserted as a piece of text without Excel seeing the quotes as a command to end the string of text to be replaced?

Hi all,

I have used the MID function in Excel to extract some values from a string. However, this is now stored as a text string of digits, which Excel doesn't recognise as a 'real' number. I would like to know how I can convert this text string into a number, so that I can use that number to do another function. I have tried using the format cells to make them into numbers instead of general but I think this only affects the appearance/formatting of the cell and not the underlying value that Excel recognises.

Thanks in advance for any help.

Without VB coding, I need to run a simple SUMIF where the condition is case dependent. Please see the attachment.

I've tried EXACT, but that's not for this purpose.

Thanks for the help.