为什么会出现错误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
1条答案
按热度按时间42fyovps1#
我在格式中使用了错误的语言:
我为我的“旧”德语系统工作,但不为“新”英语系统。
改成
成功了