So im trying to create a data base with userforms and worksheets. Inside the worksheet, ive got a table where everytime I fill up textboxes, comboboxes etc. and click a button (everything inside a userform), the information within these objects is being saved in a new row under the table, and it becomes part of the table, but different columns, in the existing table.
Right now Ive got a table with 100 rows and 63 columns. EVERY COLUMN IS FILLED WITH SOMETHING WHEN I CLICK THE BUTTON IN THE USERFORM.
while testing, I had like 40 columns and everything was fine, I could create a new row at the bottom of the table and save the information Then, I added more columns until having 63.
Now when I want to save the information, this error pops out:
method cells of object _worksheet failed
Apparently an automation error (which I have no idea what does that mean)
So doing research, it might be something about connection issues or the size (kb) of my userform, or my userforms being ShowModal:=True.
I set my userforms to Showmodal:= False, the size of my userform is no more than 35 kb, and as my understanding, the max size can be up top 64kb, so I dont think that's failing.
When reviewing my table, I added a blank extra row manually and the error is gone. Seems like the program isn't recognizing any cell outside my table, which it did when I was testing with 40 columns, and is provoking this error.
BUT... I didnt change the code when adding the columns, when I had 40 columns, everything worked, I even tried to explicit add a new row to my table and write on that row, but the same error keeps popping. Could be a loop somewhere?
IMPORTANT INFORMATION: Every userform is set to ShowModal:= False, I have 15 userforms, right now i have 100 rows and 63 columns.
Hope you can help, I've been trying to solve this issue for weeks
Here's part of my code to write on the worksheet:
Private Sub btn_Confirmar_Click()
Dim i As Double
Dim final As Double
Application.ScreenUpdating = False
Worksheets("BaseDeDatos").Visible = True
Worksheets("BaseDeDatos").Select
final = Range("A" & Rows.Count).End(xlUp).Row + 1
For i = 2 To final
If Worksheets("BaseDeDatos").Cells(i, 1) = "" Then
final = i
Exit For
End If
Next
'GRABAMOS ALTA NUEVO CLIENTE
Worksheets("BaseDeDatos").Cells(final, 1) = ufNuevoCliente.tb_NumeroCliente.value
Worksheets("BaseDeDatos").Cells(final, 2) = ufNuevoCliente.tb_NumeroFactura.value
' Worksheets("BaseDeDatos").Cells(final, 3) = ufNuevoCliente.tb_NombreCliente
' Worksheets("BaseDeDatos").Cells(final, 4) = ufNuevoCliente.tb_ApellidoPaternoCliente
' Worksheets("BaseDeDatos").Cells(final, 5) = ufNuevoCliente.tb_ApellidoMaternoCliente
Worksheets("BaseDeDatos").Cells(final, 6) = ufNuevoCliente.tb_NombreResp.value
Worksheets("BaseDeDatos").Cells(final, 7) = ufNuevoCliente.tb_ApellidoPaternoResp
Worksheets("BaseDeDatos").Cells(final, 8) = ufNuevoCliente.tb_ApellidoMaternoResp
Worksheets("BaseDeDatos").Cells(final, 9) = ufNuevoCliente.tb_Pais
Worksheets("BaseDeDatos").Cells(final, 10) = ufNuevoCliente.tb_Estado
Worksheets("BaseDeDatos").Cells(final, 11) = ufNuevoCliente.tb_CiudadMunicipio
Worksheets("BaseDeDatos").Cells(final, 12) = ufNuevoCliente.tb_Colonia
Worksheets("BaseDeDatos").Cells(final, 13) = ufNuevoCliente.tb_Calle
Worksheets("BaseDeDatos").Cells(final, 14) = ufNuevoCliente.tb_NoExt
Worksheets("BaseDeDatos").Cells(final, 15) = ufNuevoCliente.tb_NoInt
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Unload Me
End sub
Bookmarks