astonish
astonish

Reputation: 223

should be only one Header in excel sheet

enter image description here

i have to format an excel sheet. it contains multiple of empty rows, haeders repeated after several rows. New at vb script and this type of excel work. how can i do this. can some one help me in macro coding of this??? here is the snapshot

Upvotes: 1

Views: 88

Answers (1)

user3421897
user3421897

Reputation: 11

I would tackle a project with a for/next loop. You can get the total number of lines in the report so you know when to stop looking for things to format. You can make any sort of test you want in the loop with if and end if statements. Here is an example that changes the format of any data that is in the first column.

Option Explicit
Sub Format_Report()

Dim Nbr_of_Sheets As Integer
Dim LastLine_Data As Long
Dim Loop_Ctr As Long
Dim LastLine_Plug_Code As Long

Application.ScreenUpdating = False

Nbr_of_Sheets = ActiveWorkbook.Sheets.Count

Sheet1.Select  ' Always select sheet 1 no matter what the name
Range("A1").Select
LastLine_Data = Cells(Rows.Count, "A").End(xlUp).Row
For Loop_Ctr = 1 To LastLine_Data
    If Cells(Loop_Ctr, 1).Value <> "" Then

        With Cells(Loop_Ctr, 1)
            .Font.Bold = True
            .Font.Name = "Arial Black"
            .Font.Size = 14
        End With

    End If
Next Loop_Ctr
Application.ScreenUpdating = True

End Sub

Upvotes: 1

Related Questions