Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
xpath error? Runtime Error 13 type mismatch Steve M[_2_] Excel Discussion (Misc queries) 0 January 17th 08 01:16 AM
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Type Mismatch Error Need Help Ray Batig Excel Programming 1 September 16th 03 12:57 AM


All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"