excel 错误1004:无法设置Range类的NumberFormat属性?

pcrecxhr  于 2023-05-19  发布在  其他
关注(0)|答案(1)|浏览(314)

为什么会出现错误1004:无法设置Range类的NumberFormat属性?

Sub ReadFile(fileName As String)
    Dim projectWb As Workbook
    Dim lastRow As Long
    Dim lastRowOutput As Long
    Dim row As Long

    Application.ScreenUpdating = False

    Set projectWb = Workbooks.Open(Range("folderPath") & fileName, False)

    lastRow = projectWb.Sheets("Beställningar").Cells.Find("*", [A1], xlValues, , xlByRows, xlPrevious).row

    For row = 64 To lastRow
            lastRowOutput = ThisWorkbook.Sheets("Output").Cells.Find("*", [A1], xlValues, , xlByRows, xlPrevious).row
            'The folloing line works
            ThisWorkbook.Sheets("Output").Range("F" & lastRowOutput + 1 & ":" & "M" & lastRowOutput + 1).Value = projectWb.Sheets("Beställningar").Range("B" & row & ":" & "I" & row).Value 'Beställning
            'The following line generates Error1004: unable to set the NumberFormat property of the Range class?
            ThisWorkbook.Sheets("Output").Range("F" & lastRowOutput + 1 & ":" & "M" & lastRowOutput + 1).NumberFormat = projectWb.Sheets("Beställningar").Range("B" & row & ":" & "I" & row).NumberFormat 'Beställning
    Next row

    'close without saving
    Application.DisplayAlerts = False
    projectWb.Close (False)
    Application.DisplayAlerts = True

    Application.ScreenUpdating = True
End Sub
42fyovps

42fyovps1#

我在格式中使用了错误的语言:

,#_ ;[Rot]-#,#

我为我的“旧”德语系统工作,但不为“新”英语系统。
改成

"#,#_ ;[Red]-#,#"

成功了

相关问题