Looking for Assisttance: Copy and Past as Values VBA Coding

bepedicino

Board Regular
Joined
Sep 29, 2014
Messages
73
I am a newbiee with no VBA experince. I have the following code that copies all sheets and then paste it as values. I would some assistance if someone could please modify the code to unhide all hidden columns first and then past all as values. If possible, I would then like it to delete all sheets other than the one that I have selected.

Any help would be greatly appreciated!

Sub Test()
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
If Sh.Visible = True Then
Sh.Activate
Sh.Cells.Copy
Sh.Range("A1").PasteSpecial Paste:=xlValues
Sh.Range("A1").Select
End If
Next Sh
Application.CutCopyMode = False
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
What you're asking for and what your code does are somewhat different. But here's the code:

Code:
Sub valuesAndDelete()

    With Application
        .Calculate
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .DisplayAlerts = False
    End With

    With ActiveSheet
        .Columns.Hidden = False
        .Rows.Hidden = False
        .UsedRange.Value = .UsedRange.Value
    End With
    
    For Each Worksheet In ThisWorkbook.Worksheets
        If Worksheet.Name = ActiveSheet.Name Then
        Else
            Worksheet.Delete
        End If
    Next Worksheet

    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .DisplayAlerts = True
    End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,237
Messages
6,123,807
Members
449,127
Latest member
Cyko

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