我的代码:
appsettings.custom.json
答案 0 :(得分:0)
CELL()
分配给该单元格而不是该单元格的值。CELL("filename")
函数,该函数仅在保存工作簿后才能使用,如果您只想使用名称,则希望使用ThisWorkbook.Name
;如果要使用路径,请使用ThisWorkbook.FullName
名字。Sub InsertFileName()
Dim LastRow As Long
Dim LastColumn As Long
Application.ScreenUpdating = False
Dim i As Long
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
LastColumn = ActiveSheet.Cells(i, ActiveSheet.Columns.Count).End(xlToLeft).Column
ActiveSheet.Cells(i, LastColumn + 1).value2 = "=CELL(""filename"")"
'ActiveSheet.Cells(i, LastColumn + 1).value2 = ThisWorkbook.Name 'or ThisWorkbook.FullName
Next i
Application.ScreenUpdating = True
End Sub