User-defined type not defined

S

shapper

Hello,

I have a Worksheet with 36 images all them having a name.

I also have a button that run clicked runs the Macro "Play". And I
have the following code:

Private Sub Workbook_Open()

Option Explicit

Type TpJogo
fig(1 To 6, 1 To 6) As String
LastRow As Integer
LastCol As Integer
Score As Integer
End Type ' TpJogo

Public jogo As TpJogo

Sub Play()

With jogo
.fig = ("gar2")
.LastRow = 8
.LastCol = 7
.Score = 0
End With

Coloca_Pos(jogo, 6, 6) = 1

End Sub

Sub Coloca_Pos(ByRef jogo As TpJogo, ByVal r As Integer, ByVal c As
Integer)

Dim hc As Single, hf As Single, wc As Single, wf As Single
Dim nf As String
On Error GoTo fim
With Range("tabuleiro")
hc = .Cells(r, c).Height
wc = .Cells(r, c).Width
nf = jogo.fig(r, c)
hf = ActiveSheet.Shapes(nf).Height
wf = ActiveSheet.Shapes(nf).Width
ActiveSheet.Shapes(nf).Top = .Cells(r, c).Top + (hc - hf) / 2
ActiveSheet.Shapes(nf).Left = .Cells(r, c).Left + (wc - wf) / 2
End With
fim:

End Sub ' Coloca_Pos

End Sub

When I click the I get the following error:
User-defined type not defined.

What am I doing wrong?

Thanks,
Miguel
 
J

Jim Thomlinson

You have a bunch of problems...

What is this line for.
Private Sub Workbook_Open()

You defined fig as an array so you can not just assign to it
..fig = ("gar2")

Coloca_Pos is a sub so the = sign makes no sense
Coloca_Pos(jogo, 6, 6) = 1

You have 2 end subs in one procedure.
End Sub ' Coloca_Pos
End Sub

Probably not a problem but you defined
LastRow As Integer
but integer maxed out at 32k. There are 65k rows.
 

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