Run time error 13 - type mismatch

K

KG Old Wolf

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
 
G

Gary''s Student

Early in the code:

Dim CC_Count as Long, RR_Count as Long

and then:

Offset(RR_Count, CC_Count)

should work
 
K

KG Old Wolf

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!)


=====================================
 
D

Dave Peterson

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 & "*"
 
K

KG Old Wolf

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
 
D

Dave Peterson

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???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top