Help Full code for Delete operations
http://www.mvps.org/dmcritchie/excel/delempty.htm
Sub AllFolderFiles()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\Ravi\ExcelFiles"
ChDir MyPath
TheFile = Dir("*.xl*")
Do While TheFile <> ""
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
MsgBox wb.FullName
i = 1
wb.Activate
Rem wb.Application.Range("C1:C13").Formula = "=A" & i & "*B" & i
Rem AL = AJ * AK
wb.Application.Range("AL1:AL500").Formula = "=AJ1:AJ500*AK1:AK500"
Rem "=AJ" & i & "*AK" & i
Rem = AV * AW
wb.Application.Range("AX1:AX500").Formula = "=AV1:AV500*AW1:AW500"
Rem "=AV" & i & "*AW" & i
Rem BJ = BH * BI
wb.Application.Range("BJ1:AX500").Formula = "=BH1:BH500*BI1:BI500"
Rem "=BH" & i & "*BI" & i
Rem BV = BT * BU
wb.Application.Range("BV1:AX500").Formula = "=BT1:BT500*BU1:BU500"
Rem "=BT" & i & "*BU" & i
DeleteExcelSheetColumns
Rem wb.Range("A1:A500").Formula = "=A" & i * "C" & i
Rem cell.SetAddInFormula("FileInLibraryDir.xla", "=FuncName(A1,A2:A7,...)")
wb.Save
wb.Close
i = i + 1
TheFile = Dir
Loop
End Sub
Sub DeleteGroupColumns(DeleteRange As Range)
' Deletes all empty columns in DeleteRange
' Example: DeleteEmptyColumns Selection
' Example: DeleteEmptyColumns Range("A1:Z1")
Dim cCount As Integer, c As Integer
If DeleteRange Is Nothing Then Exit Sub
If DeleteRange.Areas.Count > 1 Then Exit Sub
With DeleteRange
cCount = .Columns.Count
For c = cCount To 1 Step -1
If Application.CountA(.Columns(c)) = 0 Then
.Columns(c).EntireColumn.Delete
End If
Next c
End With
End Sub
Sub DeleteExcelSheetColumns()
Worksheets("Sheet1").Range("A1:A1").Formula = "=COUNTIF(A7:BV7,""Plan Revenue"")"
If (ActiveCell.Value <> 5) Then
ActiveCell.Value = ""
DeleteGroupColumns Range("F1:N1")
DeleteGroupColumns Range("AD1:AL1")
DeleteGroupColumns Range("AG1:AO1")
DeleteGroupColumns Range("AJ1:AR1")
Worksheets("Sheet1").Range("B1:B1").Formula = "=COUNTIF(A7:BV7,""Plan Revenue"")"
ActiveCell.Value = ""
ActiveWorkbook.Save
End If
Rem Caliculate
End Sub
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment