Skip to content

Instantly share code, notes, and snippets.

@hafuu
Created January 28, 2014 04:17
Show Gist options
  • Select an option

  • Save hafuu/8662191 to your computer and use it in GitHub Desktop.

Select an option

Save hafuu/8662191 to your computer and use it in GitHub Desktop.
数式を展開するマクロ
Sub expandAll()
Dim sw
sw = Timer
Dim ss
Set ss = Sheets
For i = 1 To ss.Count
Dim s
Set s = ss(i)
Dim orig
orig = s.EnableCalculation
s.EnableCalculation = False
Dim used
Set used = s.Range(s.PageSetup.PrintArea)
Dim cols
Dim rows
cols = used.Columns.Count
rows = used.rows.Count
For Row = 1 To rows
For col = 1 To cols
Dim c
Set c = used.Cells(Row, col)
If c.HasFormula Then
c.Formula = c.Text
End If
Next col
Next Row
s.EnableCalculation = orig
Next i
Application.StatusBar = Timer - sw
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment