kieuthitran
Guest
Ðề: Excel và những vấn đề bạn ít biết
Bài viết này rất bổ ích. tks nhiều nhé
Bài viết này rất bổ ích. tks nhiều nhé
Nếu chỉ vài trăm công thức thì nên xài macro sau:Lính mới xin chào các bác (?)
Đôi khi trong Workbook nhiều công thức qúa, nên khó theo dõi . Để tiện theo dõi,, copy rồi paste vào trong Module . Run là xong
Mã:Sub ListAllFormulas() Application.DisplayAlerts = True End Sub
Option Explicit
[B]Sub ListAllFormulas()[/B]
'[COLOR="#0000FF"]Print The Formulas In The Active Workbook[/COLOR]'
Dim WB As Workbook, WS As Worksheet, wsNew As Worksheet, Cls As Range, rngF As Range
Dim strNew As String, strSh As String
On Error Resume Next
Application.DisplayAlerts = False
Set WB = ActiveWorkbook
Sheets("Formulas").Select
ActiveWindow.SelectedSheets.Delete
Set wsNew = Worksheets.Add
With wsNew
.Name = "Formulas"
.Columns("B:D").NumberFormat = "@" [COLOR="#0000FF"] 'Text Format'[/COLOR]
End With
For Each WS In WB.Worksheets
Set rngF = Nothing '*'
Set rngF = WS.Cells.SpecialCells(xlCellTypeFormulas, 23)
If Not rngF Is Nothing Then
With Sheets("Formulas").[A65500].End(xlUp)
.Offset(2).Resize(, 2).Value = Array("Sheet", WS.Name)
.Offset(3).Resize(, 4).Value = Array("ID", "Cell", "Formula", "Formula R1C1")
.Offset(2).Resize(2, 4).Font.Bold = True
.Offset(2).Resize(2, 4).HorizontalAlignment = xlCenter
End With
For Each Cls In rngF
With Sheets("Formulas").[A65500].End(xlUp)
.Offset(1).Resize(, 4).Value = _
Array(WS.Index, Cls.Address, Cls.Formula, Cls.FormulaR1C1)
End With
Next Cls
End If
Next WS
Sheets("Formulas").Columns("A:D").EntireColumn.AutoFit
Application.DisplayAlerts = True
[B]End Sub[/B]