Code:
Sub WorkBook_Open()
RemoveEmptyRow
ConcatenateColumn
DeleteBlankColumns
SaveFile
End Sub
Sub SaveFile()
'ActiveWorkbook.Save
ThisWorkbook.Saved = True
Application.Quit
Application.ActiveWindow.Close SaveChanges:=True
ActiveWorkbook.Close SaveChanges:=True
'ActiveWorkbook.SaveCopyAs ("D:\save\" & Format(Now, "ddmmyy") & ".xls")
'ActiveWorkbook.SaveAs filename:="D:\RESULT\" & Format(Now, "ddmmyy") & ".xls", FileFormat:=xlCurrentPlatformText, CreateBackup:=False
'ActiveWorkbook.SaveAs Filename:="D:\RESULT\Text.txt", FileFormat:=xlCurrentPlatformText, CreateBackup:=False
End Sub
Sub RemoveEmptyRow()
Dim i As Long
Dim DelRange As Range
On Error GoTo Whoa
Application.ScreenUpdating = False
'Path = ThisWorkbook.Path
'Path = ActiveWorkbook.Path
For i = 1 To 1500
If Application.WorksheetFunction.CountA(Range("A" & i & ":" & "DG" & i)) = 0 Then
If DelRange Is Nothing Then
Set DelRange = Rows(i)
Else
Set DelRange = Union(DelRange, Rows(i))
End If
End If
Next i
If Not DelRange Is Nothing Then DelRange.Delete Shift:=xlUp
LetsContinue:
Application.ScreenUpdating = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume LetsContinue
ActiveWorkbook.Save
End Sub
Sub ConcatenateColumn()
'Path = ActiveWorkbook.Path
'For i = A To Cells(Rows.Count, "BE").End(xlUp).Row
For i = 1 To Cells(Rows.Count, "BE").End(xlUp).Row
Cells(i, "BE").Value = Cells(i, "BE").Value & Cells(i, "BF").Value
Next i
For i = 1 To Cells(Rows.Count, "AE").End(xlUp).Row
Cells(i, "AE").Value = Cells(i, "AE").Value & Cells(i, "AF").Value & Cells(i, "AG").Value
Next i
For i = 1 To Cells(Rows.Count, "G").End(xlUp).Row
Cells(i, "G").Value = Cells(i, "G").Value & Cells(i, "H").Value
Next i
For i = 1 To Cells(Rows.Count, "K").End(xlUp).Row
Cells(i, "K").Value = Cells(i, "K").Value & Cells(i, "L").Value
Next i
For i = 1 To Cells(Rows.Count, "M").End(xlUp).Row
Cells(i, "M").Value = Cells(i, "M").Value & Cells(i, "N").Value
Next i
For i = 1 To Cells(Rows.Count, "AI").End(xlUp).Row
Cells(i, "AI").Value = Cells(i, "AI").Value & Cells(i, "AJ").Value & Cells(i, "AK") & Cells(i, "AL")
Next i
For i = 1 To Cells(Rows.Count, "AM").End(xlUp).Row
Cells(i, "AM").Value = Cells(i, "AM").Value & Cells(i, "AN").Value & Cells(i, "AO").Value
Next i
For i = 1 To Cells(Rows.Count, "AP").End(xlUp).Row
Cells(i, "AP").Value = Cells(i, "AP").Value & Cells(i, "AQ").Value & Cells(i, "AR").Value
Next i
For i = 1 To Cells(Rows.Count, "AS").End(xlUp).Row
Cells(i, "AS").Value = Cells(i, "AS").Value & Cells(i, "AT").Value
Next i
For i = 1 To Cells(Rows.Count, "AV").End(xlUp).Row
Cells(i, "AV").Value = Cells(i, "AV").Value & Cells(i, "AW").Value
Next i
For i = 1 To Cells(Rows.Count, "BA").End(xlUp).Row
Cells(i, "BA").Value = Cells(i, "BA").Value & Cells(i, "BB").Value & Cells(i, "BC").Value
Next i
For i = 1 To Cells(Rows.Count, "BL").End(xlUp).Row
Cells(i, "BL").Value = Cells(i, "BL").Value & Cells(i, "BM").Value
Next i
For i = 1 To Cells(Rows.Count, "BP").End(xlUp).Row
Cells(i, "BP").Value = Cells(i, "BP").Value & Cells(i, "BQ").Value
Next i
For i = 1 To Cells(Rows.Count, "BS").End(xlUp).Row
Cells(i, "BS").Value = Cells(i, "BS").Value & Cells(i, "BT").Value
Next i
For i = 1 To Cells(Rows.Count, "BS").End(xlUp).Row
Cells(i, "BS").Value = Cells(i, "BS").Value & Cells(i, "BT").Value
Next i
For i = 1 To Cells(Rows.Count, "BW").End(xlUp).Row
Cells(i, "BW").Value = Cells(i, "BW").Value & Cells(i, "BX").Value
Next i
For i = 1 To Cells(Rows.Count, "CA").End(xlUp).Row
Cells(i, "CA").Value = Cells(i, "CA").Value & Cells(i, "CB").Value
Next i
For i = 1 To Cells(Rows.Count, "CH").End(xlUp).Row
Cells(i, "CH").Value = Cells(i, "CH").Value & Cells(i, "CI").Value & Cells(i, "CJ").Value
Next i
For i = 1 To Cells(Rows.Count, "CL").End(xlUp).Row
Cells(i, "CL").Value = Cells(i, "CL").Value & Cells(i, "CM").Value
Next i
For i = 1 To Cells(Rows.Count, "CO").End(xlUp).Row
Cells(i, "CO").Value = Cells(i, "CO").Value & Cells(i, "CP").Value
Next i
For i = 1 To Cells(Rows.Count, "CR").End(xlUp).Row
Cells(i, "CR").Value = Cells(i, "CR").Value & Cells(i, "CS").Value
Next i
For i = 1 To Cells(Rows.Count, "CT").End(xlUp).Row
Cells(i, "CT").Value = Cells(i, "CT").Value & Cells(i, "CU").Value
Next i
For i = 1 To Cells(Rows.Count, "CV").End(xlUp).Row
Next i
End Sub
Sub DeleteBlankColumns()
'Path = ActiveWorkbook.Path
'Declaring the variable lColumn as long to store the last Column number
Dim lColumn As Long
'Declaring the variable iCntr as long to use in the For loop
Dim iCntr As Long
'Assigning the last Column value to the variable lColumn
lColumn = 111
iCntr = 1
'Using for loop
'We are checking the each cell value if it cell is 0 (equals to zero value)
'And deleting the Column if true
For iCntr = lColumn To 1 Step -1
If Cells(1, iCntr) = 0 Then
Columns(iCntr).Delete
End If
Next
ActiveWindow.Visible = True
End Sub
"Method 'Range of object'_Global' failed"
Please help me
Comment