Domanda

Hi I have problem with this procedure:

Sub initiative(name As Range, initiative_range As Range, number As Integer)
    Worksheets("battle").Range("a6").Offset(0, number).Value = name
    Worksheets("battle").Range("b6").Offset(0, number).Value = Round(19 * Rnd) + 1 + CInt(initiative_range.Value)
End Sub

3rd line cause type mismatch problem. I call this sub using:

Call initiative(Worksheets("character").Range("AD24"), Worksheets("character").Range("b1"), 1)
È stato utile?

Soluzione

That means one of these four components is a mismatched datatype:

Worksheets("battle").Range("b6").Offset(0, number).Value 
Round(19 * Rnd) 
1 
CInt(initiative_range.Value)

Or, CInt(initiative_range.Value) can't be converted to an Integer.

Or, number is not a number

Why don't you go into debug mode and inspect each of these components and work it out.

It's probably the CInt part.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top