• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro that saves values for only certain worksheets

jassybun

Member
I am trying to do a save as values in a copy of a report that I have. This works if I Dim as a worksheet, and it goes through all the worksheets. However, because I have pivot tables now in the first six tabs, this is no longer working. Instead I would like to do a save as values for 6 particular worksheets that have formulas, and leave the pivot tables as is.

This is the formula I currently have.

I tried to change it to....Set wk = Worksheets("Sheet1") but not sure how to put it all together to look through the 6 specific sheets I need it to.

Code:
Sub SaveAsValues()
Dim ws As Worksheet

   ActiveWorkbook.RefreshAll

    For Each ws In Worksheets
     ws.UsedRange = ws.UsedRange.Value
    Next ws
  
    ThisWorkbook.SaveAs "V:\Folder"
  


End Sub
 
Last edited by a moderator:
Something along the lines of:
Code:
Sub SaveAsValues()
Dim ws As Worksheet

ActiveWorkbook.RefreshAll
Set WkShts = Sheets(Array("Sheet1", "Sheet54", "Sheet3", "Sheet6", "SheetAnother", "SheetYetAnother"))
For Each ws In WkShts
  ws.UsedRange = ws.UsedRange.Value
Next ws
ThisWorkbook.SaveAs "V:\Folder"
End Sub
 
Back
Top