我正在尝试创建一个从工作簿中获取工作表的宏,然后将该工作表保存为单个工作簿,但所有单元格都是值而不是公式。
我正在努力的是粘贴值部分。 这就是我目前所拥有的:
ThisWorkbook.Sheets("Tickets (1-48)").Copy
With ActiveWorkbook
For ColNr = 8 To 120
If Cells(RowNr, ColNr - 1) = "0" Then
TempValue = Cells(RowNr, ColNr - 1)
If TempValue = "0" Then
For i = 0 To 9
Cells(RowNr, ColNr - 1).Select
Cells(RowNr, ColNr - 1).EntireColumn.Delete
Next i
ColNr = ColNr - 1
Else
End If
Else
End If
Next ColNr
.SaveAs strpath & "\" & "Retail " & strFilename & "(1-48)" & ".xls"
.Close 0
End With
忽略中间部分。
感谢。
答案 0 :(得分:1)
我不确定您的代码在做什么,但您可以根据它进行调整。以下是录制的宏将向您显示的常规代码。
'Selects everything on the current sheet and copies it
Cells.Select
Selection.Copy
'Add a new workbook.
'Adding a new workbook makes it the active workbook so you can paste to it.
Workbooks.Add
'Paste the date using Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C8").Select