Beneindias
Board Regular
- Joined
- Jun 21, 2022
- Messages
- 120
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi guys, I need some help.
I have a file with a few macros, and it was everything working as expected, but today my excel started crashing and closing when I run one of the macros.
I was making changes to the file, and the macro was working, but sudently, It started closing excel.
The code is this:
The macro "CenterCheckbox" is not the problem here, because I already run it with no problem.
In my friends computer the macro runs with no error.
Apreciate all your help
I have a file with a few macros, and it was everything working as expected, but today my excel started crashing and closing when I run one of the macros.
I was making changes to the file, and the macro was working, but sudently, It started closing excel.
The code is this:
VBA Code:
Sub Checkboxes_Creation()
Dim lastRow As Long
Dim Sh As Worksheet
Dim worksheet1 As String: worksheet1 = "Salarios" 'Salarios
Dim PagoColumn As String: PagoColumn = "B"
Dim StatusColumn As String: StatusColumn = "C"
Dim LastRowColumn As String: LastRowColumn = "l:l" 'Include Entire Column.
Dim HRnumber As Integer
Dim table As ListObject
Dim tableData, rowData As Range
Dim countA As Integer
Set Sh = ActiveSheet
Set table = Sh.ListObjects("TabelaSalarios")
Set tableData = table.DataBodyRange
countA = 0
With Sh
'Número da última coluna da tabela
lastRow = WorksheetFunction.countA(Range(LastRowColumn))
End With
For Each rowData In tableData.Rows
'Checa se não há nenhuma checkbox na linha. O "+7", serve para ignorar as 7 linhas antes da tabela
'(não consegui fazer com que adicionasse a checkbox na linha X da tabela, pelo que tive que fazer X + 7)
If Not CheckBoxExists(Sh.Range(PagoColumn & rowData.Row)) Then
With Sh.Range(PagoColumn & rowData.Row)
'Criação da checkbox e suas definições na coluna B (Pago)
With Sh.CheckBoxes.Add(Cells(rowData.Row, PagoColumn).Left, Cells(rowData.Row, PagoColumn).Top, 10, 10)
.Caption = ""
.Locked = False
.LockedText = False
.Value = xlOff
.LinkedCell = Cells(rowData.Row, StatusColumn).Address
End With
'Chama o código para centrar a Checkbox na célula
Call CenterCheckbox
End With
End If
countA = countA + 1
Next
End Sub
The macro "CenterCheckbox" is not the problem here, because I already run it with no problem.
In my friends computer the macro runs with no error.
Apreciate all your help