Type mismatch in excel array

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
I'm creating a macro in vbaque transcribes the values that were assigned to the variables in a specific Excel sheet, it happens that when the program tries to write these values it gives "crash" and the error "Type Mismatch" appears, can someone help me?


VBA Code:
Private Sub bt_seguinte_Click()

Select Case True

Case (Trim(cb_autor) = "" Or cb_autor.ListIndex = -1) And Trim(cb_livros) = "" Or cb_livros.ListIndex = -1
    lb_erro_autor.Visible = True
    lb_erro_livros.Visible = True
   
Case Trim(cb_autor) = "" Or cb_autor.ListIndex = -1
    lb_erro_autor.Visible = True
   
Case Trim(cb_livros) = "" Or cb_livros.ListIndex = -1
    lb_erro_livros.Visible = True
   
Case lb_stock_unidades <= 0
   
   
Case Else

Dim contar_other_requisicoes As Long

Workbooks(OtherBookPath).Sheets("Requisições").Activate

contar_other_requisicoes = Cells(Rows.Count, "D").End(xlUp).Offset(1, 0).Row

autor = cb_autor.Value
livro = cb_livros.Value

Error there
------------------------
Range(Cells(contar_other_requisicoes, 2), Cells(contar_other_requisicoes, 8)) = Array(contar_other_requisicoes - 1, nome_usuario, autor, livro, Format(Now, "hh:mm"), Format(Now, "dd/mm/aaaa"), DateAdd("d", 30, Format(Now, "dd/mm/aaaa")))
----------------

End Select

End Sub


Capturar.JPG
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Change this:
Rich (BB code):
Format(Now, "dd/mm/aaaa"), DateAdd("d", 30, Format(Now, "dd/mm/aaaa")))

For this:
Rich (BB code):
Format(Now, "dd/mm/yyyy"), DateAdd("d", 30, Format(Now, "dd/mm/yyyy")))
 
Upvote 0
Solution
Change this:
Rich (BB code):
Format(Now, "dd/mm/aaaa"), DateAdd("d", 30, Format(Now, "dd/mm/aaaa")))

For this:
Rich (BB code):
Format(Now, "dd/mm/yyyy"), DateAdd("d", 30, Format(Now, "dd/mm/yyyy")))
I forgot that ahaha, in Portugal we say "Ano" so I put "aaaa", thanks for the help friend ?
 
Upvote 0
In Spanish it is also "Año" and also, on some occasions, the same thing happens to me ?
 
Upvote 0

Forum statistics

Threads
1,225,155
Messages
6,183,211
Members
453,151
Latest member
Lizamaison

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top