Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
mismatch error in returning concatonation of numbers and characters
I have two cells in a row. By the nature of formulas within the cell they will either have a number, or the text "n/a". I want to write loop that will look into the second cell to see if "n/a" is present. If it is "n/a" I want what is contained in the first cell to b returned to a text box (t1), which could be a number or could be "n/a" If the second cell contains a number, the first cell will also contai a number, and I want both numbers returned to the text box (t1) with comma between them. ie "15 , 16" or "15 , 15" etc..... I then wan the loop to continue through 13 different sets of cells with on corresponding text box. Here is what I have for the first set o cells. 'Declare Variables Dim Counter As Integer Dim a As Byte Dim b As Byte Dim c As String 'Activate Worksheet and define range Worksheets("Sheet1").Activate 'Initialize Variables Counter = 0 a = 9 b = 3 c = Cells(b, a) 'Return values from cells Do If c = "n/a" Then t1 = ActiveSheet.Cells(b, a - 1) Else: t1 = ActiveSheet.Cells(b, a - 1) + "," + ActiveSheet.Cells(b a) End If Counter = Counter + 1 Loop Until Counter = 1 I keep getting a type mismatch error. I think this is because I hav numbers being returned in concatonation with a string characte (the comma). Is there a way to convert those numbers to a string s that I will not have this error? Or am I wrong about why I'm gettin the error? Thanks to anyone that can help me -- skrimp ----------------------------------------------------------------------- skrimpy's Profile: http://www.excelforum.com/member.php...fo&userid=1463 View this thread: http://www.excelforum.com/showthread.php?threadid=26265 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
mismatch error in returning concatonation of numbers and characters
Hi,
try using & instead of + regards, Don "skrimpy" wrote in message ... I have two cells in a row. By the nature of formulas within the cells they will either have a number, or the text "n/a". I want to write a loop that will look into the second cell to see if "n/a" is present. If it is "n/a" I want what is contained in the first cell to be returned to a text box (t1), which could be a number or could be "n/a". If the second cell contains a number, the first cell will also contain a number, and I want both numbers returned to the text box (t1) with a comma between them. ie "15 , 16" or "15 , 15" etc..... I then want the loop to continue through 13 different sets of cells with one corresponding text box. Here is what I have for the first set of cells. 'Declare Variables Dim Counter As Integer Dim a As Byte Dim b As Byte Dim c As String 'Activate Worksheet and define range Worksheets("Sheet1").Activate 'Initialize Variables Counter = 0 a = 9 b = 3 c = Cells(b, a) 'Return values from cells Do If c = "n/a" Then t1 = ActiveSheet.Cells(b, a - 1) Else: t1 = ActiveSheet.Cells(b, a - 1) + "," + ActiveSheet.Cells(b, a) End If Counter = Counter + 1 Loop Until Counter = 1 I keep getting a type mismatch error. I think this is because I have numbers being returned in concatonation with a string character (the comma). Is there a way to convert those numbers to a string so that I will not have this error? Or am I wrong about why I'm getting the error? Thanks to anyone that can help me. -- skrimpy ------------------------------------------------------------------------ skrimpy's Profile: http://www.excelforum.com/member.php...o&userid=14634 View this thread: http://www.excelforum.com/showthread...hreadid=262653 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
xpath error? Runtime Error 13 type mismatch | Excel Discussion (Misc queries) | |||
xpath error? Runtime Error 13 type mismatch | Excel Discussion (Misc queries) | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming | |||
Type Mismatch Error Need Help | Excel Programming |