Share via

Replacement for Command Button/VBA

Anonymous
2013-04-04T05:11:49+00:00

Hi,

I have a excel sheet with command button which runs VBA program.The VBA runs fine in the Excel in Windows.But for Mac it shows an error Object not found.Later only i came to know that the ActiveX controls doesnt work in the Excel 2011 Mac.

Below is the code.

Please suggest me what should I do to get the same result while using the form button.

Private Sub CommandButton1_Click() 'adding extra rows

ActiveSheet.Unprotect "password"

Application.ScreenUpdating = False

'UserForm1.Show

Dim x As Integer

'Dim Nr As Range

On Error GoTo errorhandler

x = Application.InputBox("Enter the no of rows to be inserted (1-50)", "Insert Rows", Type:=1)

If x > 0 And x <= 50 Then

i = Sheet5.Cells(22, 2)

j = Sheet5.Cells(23, 2)

Sheet3.Cells(i, j).Select

'Range(i&:&i).Select

Range(ActiveCell, ActiveCell.Offset(x - 1, 0)).EntireRow.Insert Shift:=xlDown

Sheet5.Cells(24, 2) = x + Sheet5.Cells(19, 2)

Nr = Sheet5.Cells(25, 2)

ActiveSheet.ListObjects("Table5").Resize Range(Nr)

ElseIf x < 0 And x > 51 Then

MsgBox "Enter value between 1 and 100", vbOKOnly, "Input Error"

ElseIf x = "" Then

MsgBox "Enter value between 1 and 100", vbOKOnly, "Input Error"

End If

errorhandler:

ActiveSheet.Protect "password"

End

Application.ScreenUpdating = True

ActiveSheet.Protect "password"

End Sub

Thanks and Regards,

Devpp

Microsoft 365 and Office | Excel | For home | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-04-04T11:54:56+00:00

The code is fine, the problem is the button. Simply delete the active-x button, and add a new one from the forms tool bar, or from the Mac's developer ribbon. assign it to the macor and it should work fine on both platforms.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2013-04-05T06:45:46+00:00

    I replaced the buttons and its working fine now!!!

    Thank you!

    Was this answer helpful?

    0 comments No comments