ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run time error 13 - type mismatch (https://www.excelbanter.com/excel-programming/434197-run-time-error-13-type-mismatch.html)

KG Old Wolf

Run time error 13 - type mismatch
 
The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB

Gary''s Student

Run time error 13 - type mismatch
 
Early in the code:

Dim CC_Count as Long, RR_Count as Long

and then:

Offset(RR_Count, CC_Count)

should work
--
Gary''s Student - gsnu200905


"KG Old Wolf" wrote:

The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB


KG Old Wolf

Run time error 13 - type mismatch
 
Hi -

Nope - just relocated the "Error 13 - Type Mismatch" to the earlier line of
code:


RR_Count = Range("Table_Input").Offset(BB, 2)


(I had tried that and Integer to no avail but thank you for trying!)


=====================================

"Gary''s Student" wrote:

Early in the code:

Dim CC_Count as Long, RR_Count as Long

and then:

Offset(RR_Count, CC_Count)

should work
--
Gary''s Student - gsnu200905


"KG Old Wolf" wrote:

The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB


Dave Peterson

Run time error 13 - type mismatch
 
Is Table_input a single cell or multiple cells?

If it's multiple cells, maybe you want:
RR_Count = Range("Table_Input").cells(1,1).Offset(BB, 2).Value

I'd add a couple of lines to make sure I could see what's in RR_Count and
CC_Count:

'right after you determine that value
msgbox "*" & RR_Count & "*"

KG Old Wolf wrote:

The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB


--

Dave Peterson

KG Old Wolf

Run time error 13 - type mismatch
 
Dave -

Yes, "Table_Input" is a multi-cell table (13,040R * 5C). I had a feeling I
needed to have a Cells Property (?) in the line.

What I learned is I need to "limit" to the the cell -- I think the "offset"
basically said "From this point, consider the REST of the range as data to be
placed in the RR_Count & CC_Count variables) when all I wanted was the
contents of the cell at the offset's intersection.

Thanks for the help and the lesson!
Ken



"Dave Peterson" wrote:

Is Table_input a single cell or multiple cells?

If it's multiple cells, maybe you want:
RR_Count = Range("Table_Input").cells(1,1).Offset(BB, 2).Value

I'd add a couple of lines to make sure I could see what's in RR_Count and
CC_Count:

'right after you determine that value
msgbox "*" & RR_Count & "*"

KG Old Wolf wrote:

The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB


--

Dave Peterson


Dave Peterson

Run time error 13 - type mismatch
 
But you learned that .offset said to keep the same sized range as what's being
adjusted--just move it to the right/left/up/down. Right???

KG Old Wolf wrote:

Dave -

Yes, "Table_Input" is a multi-cell table (13,040R * 5C). I had a feeling I
needed to have a Cells Property (?) in the line.

What I learned is I need to "limit" to the the cell -- I think the "offset"
basically said "From this point, consider the REST of the range as data to be
placed in the RR_Count & CC_Count variables) when all I wanted was the
contents of the cell at the offset's intersection.

Thanks for the help and the lesson!
Ken

"Dave Peterson" wrote:

Is Table_input a single cell or multiple cells?

If it's multiple cells, maybe you want:
RR_Count = Range("Table_Input").cells(1,1).Offset(BB, 2).Value

I'd add a couple of lines to make sure I could see what's in RR_Count and
CC_Count:

'right after you determine that value
msgbox "*" & RR_Count & "*"

KG Old Wolf wrote:

The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB


--

Dave Peterson


--

Dave Peterson

KG Old Wolf

Run time error 13 - type mismatch
 
I just did.... another piece just fell into place....
Thanks Dave


"Dave Peterson" wrote:

But you learned that .offset said to keep the same sized range as what's being
adjusted--just move it to the right/left/up/down. Right???

KG Old Wolf wrote:

Dave -

Yes, "Table_Input" is a multi-cell table (13,040R * 5C). I had a feeling I
needed to have a Cells Property (?) in the line.

What I learned is I need to "limit" to the the cell -- I think the "offset"
basically said "From this point, consider the REST of the range as data to be
placed in the RR_Count & CC_Count variables) when all I wanted was the
contents of the cell at the offset's intersection.

Thanks for the help and the lesson!
Ken

"Dave Peterson" wrote:

Is Table_input a single cell or multiple cells?

If it's multiple cells, maybe you want:
RR_Count = Range("Table_Input").cells(1,1).Offset(BB, 2).Value

I'd add a couple of lines to make sure I could see what's in RR_Count and
CC_Count:

'right after you determine that value
msgbox "*" & RR_Count & "*"

KG Old Wolf wrote:

The code below works but I want to substitute the variables (RR_Count &
CC_Count) for the literals (25,0). I can confirm the correct numeric values
being obtained by the variables. Yet, as soon as I substitute the variables,
I get an error 13 - type mismatch. The values are always numerics and are
intended as displacement values for use by the offset.

I am still very new to VBA and may be missing something obvious. I tried DIM
RR_Count as Integer but that gave me a different error.

Thanks for any thoughts or suggestions...

================================================== ====

'
' Fill Output Detail Fields
'
For BB = 0 To 15 Step 1
'
' RR holds the ROW ID from the selected record in Table_Input
RR_Count = Range("Table_Input").Offset(BB, 2).Value
'
' CC holds the COLUMN ID from the selected record in Table_Input
CC_Count = Range("Table_Input").Offset(BB, 3).Value
'
'
Range("K1").Offset(25, 0).Value = Range("Table_Input").Offset(BB, 5).Value
'
'
'
Next BB

--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com