code check

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
Hi, i have this code which keeps the below sheets and deletes all other sheets, in the below statement i would like the code to copy and pastevalues for each of the below sheets, how can add this to the code

Code:
With ThisWorkbook
For Each WS In .Sheets
Select Case WS.Name
Case "Ratio", "Report", "Task"
Case Else: WS.Delete
End Select
Next
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Alisya,



From what sheet(s) to what sheet?

And, what range will be copied?


Have a great day,
Stan


Stan, this is the full code i found from another post and changed to my requirements, sheets "Ratio", "Report", "Task", these sheets i need the whole sheet as paste values

Code:
Sub test1()
Dim myName As String, myFolder As String, e
Dim fso As Object, temp As String
Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject")
myFolder = "R:\Management\Data\" & Year(Date) & "\" & Format$(Date, "mmm")
myName = "Reporting V1.xls"
Application.DisplayAlerts = False
With ThisWorkbook
    For Each WS In .Sheets
        Select Case WS.Name
            Case "Ratio", "Report", "Task"
            Case Else: WS.Delete
        End Select
    Next
    Application.DisplayAlerts = True
    .SaveAs myFolder & "\" & myName
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Alisya,

sheets "Ratio", "Report", "Task", these sheets i need the whole sheet as paste values

Do you want each of these sheets, "Ratio", "Report", "Task", to have all the cells/formulae/etc. copied and then paste special values back on to themselves?


Have a great day,
Stan
 
Upvote 0
Maybe,
Code:
            Case "Ratio", "Report", "Task"
                ws.UsedRange.Copy: ws.PasteSpecial xlPasteValues
            Case Else: ws.Delete
Note that the above is "destructive" in that it replaces formulas in the designated worksheets with the values. So, if that is not what you want...
Hi, i have this code which keeps the below sheets and deletes all other sheets, in the below statement i would like the code to copy and pastevalues for each of the below sheets, how can add this to the code

Code:
With ThisWorkbook
For Each WS In .Sheets
Select Case WS.Name
Case "Ratio", "Report", "Task"
Case Else: WS.Delete
End Select
Next
 
Upvote 0
Maybe,
Code:
            Case "Ratio", "Report", "Task"
                ws.UsedRange.Copy: ws.PasteSpecial xlPasteValues
            Case Else: ws.Delete
Note that the above is "destructive" in that it replaces formulas in the designated worksheets with the values. So, if that is not what you want...



i get an error on paste values part

WS.PasteSpecial xlPasteValues
 
Upvote 0
Alisya,

Try:

Code:
            Case "Ratio", "Report", "Task"
                With ws.UsedRange
                    .Value = .Value
                End With
            Case Else: ws.Delete


Have a great day,
Stan
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,215
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top