lỗi đăng ký vba excel ngoài phạm vi
Mã này hoạt động cho khoảng 50% số trang tính trong Sổ làm việc:
Trang tính(shtnamelc).Không bảo vệ Trang tính(shtnamelc).Range("$Q$6").value = tmp
> Trang tính(shtnamelc).Protect AllowFormattingCells:=True, AllowFormattingColumns:=TrueSổ làm việc của tôi có bị hỏng không? Làm thế nào để tôi sửa chữa nó?
Mã trong vĩ mô:
Application.EnableEvents = True
> > For i = 0 To NumOptions > shtname = OptionL(i) > shtnamelc = shtname & " Lc" > shtnamelong = shtname & " Long Call" > tmp = Utils.GetStkPrice(shtname) > > If tmp = 0 Then > MsgBox ("Không tìm thấy giá cổ phiếu cho tùy chọn " & shtname & ".") > Đi tới L2 > Kết thúc Nếu > > 'Gọi Utils.subClosingPopUp(4, "Cập nhật giá cổ phiếu hiện tại cho " &shtname & ".", "Giá cổ phiếu" ) > > Worksheets(shtnamelc).Unprotect > Worksheets(shtnamelc).Range("$Q$6").value = tmp > Worksheets(shtnamelc).Protect AllowFormattingCells:=True, AllowFormattingColumns:=True > > Worksheets(shtname). Bỏ bảo vệ > Worksheets(shtname).Range("$B$8").value = tmp ' cập nhật giá XXXX > Worksheets(shtname).Protect AllowFormattingCells:=True, AllowFormattingColumns:=True >L2: Next i >> Application.ScreenUpdating = True > Worksheets("Home").Protect AllowFormattingCells:=True, AllowFormattingColumns:=True
Trả lời:
Tôi phát hiện ra rằng tôi có một trang tính không hợp lệ gây ra sự cố nên tôi đã khắc phục nó bằng cách xóa và thêm lại vào sổ làm việc
Comments
Post a Comment