i'm trying to learn vba and i'm writing at the vba interface some subs that contain the content of what i'm learning. I don't know if this is an efficient method to store the commands and syntaxes that i stood, to study again later, due to this method of studying, when i'm executing/adding some new procedures, sometimes appear some messageboxes on the sheets with some random numbers(WHENEVER I ADD A NEW SUB, when i gave it a command to open another workbook, in the new wb it appears those random numbers...), i still don't know if this is a memory problem of vba or some kind of syntax error that i made by my own. An example of what code i add that was caught into this kind of error is shown below:
Sub atribuirobjeto()
Dim wb As Workbook
Dim ws As Worksheet
Dim box As Range 'variável box - para representar o range e localizar ou definir um intervalo de células
Set wb = Workbooks(1) 'precisa do set quando for atribuir a objeto
Set ws = Workbooks(1).Worksheets(1)
'ou
Set ws = wb.Worksheets(1) 'pode usar o wb para se refenciar ao objeto workbooks
'de forma similar, ws engloba o wsheet e o workboooks
Set box = ws.Range("C40")
ws.Name = "anotacoes_vba"
box.Value = 14
Debug.Print TypeName(box)
End Sub
One of the msgboxes that appears