Worksheet Paste values/Save as then return the ori

2019-08-22 14:34发布

I have a workbook which performs several Excel-functions that depend on one variable and fills out itself. I have a loop to create those forms and save in a directory but before that I want to copy all and paste special so that formulas will be gone.

Sub SaveAs1()
For i = 172 To 225 
    Dim SaveName As Integer
    SaveName = ActiveWorkbook.Sheets(1).Range("bi1").value
    Application.ActiveWorkbook.SaveAs "C:\" & SaveName
    Range("bi1") = i + 1
Next
End Sub

I figure that out finally using trial and error method

Sub Save()

Rem kaydetmece dongusu

For i = 172 To 180 Step 1

    Application.DisplayAlerts = False

    Workbooks.Open Filename:="C:\"

    Range("bi1") = i + 1

    Dim SaveName As Integer
    SaveName = ActiveWorkbook.Sheets(1).Range("bi1").value

    Range("A1:BE63").Select
    Range("a1").Activate
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

    Application.ActiveWorkbook.SaveAs "C:\" & SaveName

    Columns("BE:BU").Select
    Selection.Delete Shift:=xlToLeft

    Sheets("CAL").Select
    ActiveWindow.SelectedSheets.Delete

    Sheets("sahadan").Select
    ActiveWindow.SelectedSheets.Delete

    ActiveWorkbook.Close True

Next

End Sub

1条回答
聊天终结者
2楼-- · 2019-08-22 15:32

If you're asking how to paste values, this is how you do it. Replace "A1" with the actual range you need to use.

Range("A1").Copy
Range("A1").PasteSpecial xlPasteValues
查看更多
登录 后发表回答