You are on page 1of 3

Change all the cells in all worksheets to values

You can remove the sh.Select line and .Cells(1).Select line if you want.
I add it because I not like the selection of the usedrange in every sheet after you
use PasteSpecial.

Sub All_Cells_In_All_WorkSheets_1()
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Select
With sh.UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
Next sh
End Sub

Sub All_Cells_In_All_WorkSheets_2()
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
With sh.UsedRange
.Value = .Value
End With
Next sh
End Sub
Change all the cells in the ActiveSheet to values

Sub All_Cells_In_Active_WorkSheet_1()
With ActiveSheet.UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End Sub

Sub All_Cells_In_Active_WorkSheet_2()
With ActiveSheet.UsedRange
.Value = .Value
End With
End Sub
Change all the cells in the CurrentRegion to values

Use the the Shortcut Ctrl * with the A1 selected to see the CurrentRegion.
It is a range with data bounded by a empty row/column.

Sub CurrentRegion_Example_1()
With Range("A1").CurrentRegion
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End Sub
Sub CurrentRegion_Example_2()
With Range("A1").CurrentRegion
.Value = .Value
End With
End Sub
Change all the cells in a range to values

Sub Range_Example_1()
With Range("A5:D100")
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End Sub

Sub Range_Example_2()
With Range("A5:D100")
.Value = .Value
End With
End Sub
Change all the cells in a range with one or more areas to values

Sub Range_With_One_Or_More_Areas_Example_1()
Dim smallrng As Range
For Each smallrng In Range("A1:C10,E12:G17").Areas

'If you want to run the code on a selection with one or more
'areas you can use For Each smallrng In Selection.Areas

With smallrng
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
Next smallrng
End Sub

Sub Range_With_One_Or_More_Areas_Example_2()
Dim smallrng As Range
For Each smallrng In Range("A1:C10,E12:G17").Areas

'If you want to run the code on a selection with one or more
'areas you can useFor Each smallrng In Selection.Areas

With smallrng
.Value = .Value
End With
Next smallrng
End Sub
Break only formula links to other Excel workbooks

Sub Break_Links_To_other_Excel_Workbooks()
'This example convert formulas that point to another Excel workbook to values
'It will not convert other Excel formulas to values.
'Note that BreakLink is added in Excel 2002
Dim WorkbookLinks As Variant
Dim wb As Workbook
Dim i As Long

Set wb = ActiveWorkbook

WorkbookLinks = wb.LinkSources(Type:=xlLinkTypeExcelLinks)
If IsArray(WorkbookLinks) Then
For i = LBound(WorkbookLinks) To UBound(WorkbookLinks)
wb.BreakLink _
Name:=WorkbookLinks(i), _
Type:=xlLinkTypeExcelLinks
Next i
Else
MsgBox "No Links to other workbooks"
End If
End Sub

You might also like