visual basic unexpected error ( 40182)

Anonymous
2024-01-17T05:08:04+00:00

when i run it, it shows "run time error 1004, Application defined or object defined error" When I click debug, it will pop up " Microsoft Visual Basic Unexpected error (40182)"

when I opened the spreadsheet on Windows, there were no errors at all; it only happened on the MacBook

how can solve it

Microsoft 365 and Office | Excel | For business | 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
{count} votes
Answer accepted by question author
  1. Anonymous
    2024-02-04T03:07:51+00:00

    The problem was solved when I set the Excel language to Chinese; everything was good.

    0 comments No comments

10 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-01-17T06:12:05+00:00

    Could you share us your code to reproduce your issue? It seems issue with code using window reference which will not work on mac.

    0 comments No comments
  2. Anonymous
    2024-01-17T06:28:13+00:00

    it worked before but is not working now. Yes, I can share the code. Shall I send it here or ?

    0 comments No comments
  3. Anonymous
    2024-01-17T06:40:30+00:00

    If there is no sensitive information in your code, you can share it here.

    0 comments No comments
  4. Anonymous
    2024-01-17T06:55:09+00:00

    Public Sub create_new_sheet()

    ist = ActiveCell.Row '活动单元格所在的行数

    Sheets("Model").Copy Before:=Sheets("Model") '把具体跟进详情格式表复制一份,接着准备写入数据

    Sheets(ist - 1).Name = ist - 2 '表名称= 行数减 2 即要创建的跟进详情表的表名称。

    Sheets(ist - 1).Range("A1") = "=录入表!B" & ist '跟进详情表的表中 A1 单元格的值为录入总表中对应的单元格,如 C4

    Sheets(ist - 1).Range("B2") = "=录入表!A" & ist

    Sheets(ist - 1).Range("F2") = "第" & ist & "行"

    Sheets(ist - 1).Range("B3") = "=录入表!D" & ist

    Sheets(ist - 1).Range("F3") = "=录入表!E" & ist

    Sheets(ist - 1).Range("B4") = "=录入表!C" & ist

    Sheets(ist - 1).Range("F4") = "=录入表!I" & ist

    Sheets(ist - 1).Range("B5") = "=录入表!H" & ist

    Sheets(ist - 1).Range("F5") = "=录入表!K" & ist

    Sheets(ist - 1).Range("B6") = "=录入表!F" & ist

    Sheets(ist - 1).Range("F6") = "=录入表!J" & ist

    Sheets(ist - 1).Range("B7") = "=录入表!M" & ist

    Sheets(ist - 1).Range("F7") = "=录入表!L" & ist

    Sheets(ist - 1).Range("B8") = "=录入表!N" & ist

    Sheets(ist - 1).Range("B9") = "=录入表!O" & ist '依次完成所有单元格值的填充

    Sheets("录入表").Select '选择汇总表

    ActiveCell.Offset(0, 1).Select '从当前表格中本行往右偏移一个单元格

    ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:="'" & Worksheets(ist - 1).Name & "'" & "!A1"

    '添加超链接。下面的代码都是加样式,不用管。

    ActiveCell.Font.Underline = xlUnderlineStyleNone

    ActiveCell.Font.Color = RGB(5, 99, 193)

    ActiveCell.Font.Name = "Arial"

    ActiveCell.Font.Size = 10

    ActiveCell.HorizontalAlignment = xlLeft

    ActiveCell.VerticalAlignment = xlCenter

    ActiveCell.WrapText = False

    ActiveCell.Orientation = 0

    ActiveCell.AddIndent = False

    ActiveCell.IndentLevel = 1

    ActiveCell.ShrinkToFit = False

    ActiveCell.ReadingOrder = xlContext

    ActiveCell.MergeCells = False

    End Sub

    0 comments No comments