Hi experts and gurus,
I wrote the following IF NOT condition statement and would like to merge in single code.
Sub GenerateReport()
Dim lastrow As Long
Application.ScreenUpdating = False
ThisWorkbook.Worksheets("Source").Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
If Not ActiveSheet.Range("A1").MergeCells = False Then
ActiveSheet.Cells.UnMerge
End If
If Not ActiveSheet.Range("A1").Font.Name = "Arial" Then
ActiveSheet.Cells.Font.Name = "Arial"
End If
If Not ActiveSheet.Range("A1").Font.Size = 8 Then
ActiveSheet.Cells.Font.Size = 8
End If
If Not ActiveSheet.Range("A1").WrapText = False Then
ActiveSheet.Cells.WrapText = False
End If
Application.ScreenUpdating = True
End Sub
I tried with the following code but it did not work.
Sub GenerateReport()
Dim lastrow As Long
Application.ScreenUpdating = False
ThisWorkbook.Worksheets("Source").Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
If Not ActiveSheet.Range("A1").MergeCells = False Or _
ActiveSheet.Range("A1").Font.Name = "Arial" Or _
ActiveSheet.Range("A1").Font.Size = 8 Or _
ActiveSheet.Range("A1").WrapText = False Then
ActiveSheet.Cells.UnMerge
ActiveSheet.Cells.Font.Name = "Arial"
ActiveSheet.Cells.Font.Size = 8
ActiveSheet.Cells.WrapText = False
End If
Application.ScreenUpdating = True
End Sub
Could you please help me to understand my error? I appreciate your advices.
Thank you
Roshan Shakya
Bookmarks