0% found this document useful (0 votes)
19 views2 pages

HROpal RAW File To Formated FIle

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

HROpal RAW File To Formated FIle

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Function Merge_Row(rng As Range) As Long

Application.FindFormat.Clear
Application.FindFormat.MergeCells = True
On Error Resume Next
Merge_Row = rng.Find(What:="", After:=rng.Cells(rng.Cells.Count),
SearchDirection:=xlPrevious, SearchFormat:=True).row
On Error GoTo 0
Application.FindFormat.Clear
End Function
Sub RawFileConvertor()
Dim x As Integer
Dim wks As Excel.Worksheet
Dim rng As Excel.Range
Dim row As Long
Dim lastrow As Long
Dim lCol As Long
Dim FirstMergeRow As Long

Application.ScreenUpdating = False
Cells.Select
ActiveSheet.Shapes.Range(Array("Picture 1")).Select
Selection.Delete
With Selection
.MergeCells = False
End With
Cells.EntireColumn.AutoFit
' To delete the empty rows
Set wks = Excel.ActiveSheet
lastrow = Range("A" & Rows.Count).End(xlUp).row
With wks
For row = 1 To lastrow
If Application.WorksheetFunction.CountA(.Rows(row)) = 0 Then
If rng Is Nothing Then
Set rng = .Rows(row)
Else
Set rng = Excel.Union(rng, .Rows(row))
End If
End If
Next row
End With
'In order to avoid Run-time error check if [rng] range is not empty, before
removing it.
If Not rng Is Nothing Then
Call rng.EntireRow.Delete
End If
For row = 1 To 5
On Error Resume Next
lCol = Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart,
LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious,
MatchCase:=False).Column
On Error GoTo 0
If ActiveCell.Value = "" Then
Range(Cells(row, 1), Cells(row, lCol)).Select
With Selection
.HorizontalAlignment = xlCenter
.MergeCells = True
End With
End If
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Value <> "" Then
If ActiveCell.MergeCells Then
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Value = "" Then ActiveCell.EntireRow.Delete
Else
If ActiveCell.Value = "" Then ActiveCell.EntireRow.Delete
End If
End If
Next
FirstMergeRow = Merge_Row(Range("A:A")) + 1
Range(Cells(FirstMergeRow, 1), Cells(FirstMergeRow, 1)).Select
For x = 1 To lCol
If ActiveCell.Value = "" Then
ActiveCell.EntireColumn.Delete
Else
ActiveCell.Offset(0, 1).Select
End If
Next
Cells.Select
With Selection.Font
.Name = "Arial"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Application.CutCopyMode = False
Range("A1").Select
End Sub

You might also like