Slicemahn
12-20-2007, 01:20 AM
Hello Everyone!
I am trying to populate all rows of a sheet that is a result of a pasted pivot table. I have written some code in an effort to populate the cells but it overwrites or misses the key information. This task has turned out to be more challenging than I first imagined. Here is my code:
Private Sub PopulateEmptyCells()
Dim EndRow As Integer
Dim RowLooper As Integer
With ActiveSheet
EndRow = Cells(65536, 1).End(xlUp).Row
For RowLooper = 7 To EndRow
If Cells(RowLooper, 2).Value = "" Or Cells(RowLooper, 2).Value = "" Then
Cells(RowLooper, 1) = Cells((RowLooper - 1), 1).Value
Cells(RowLooper, 2) = Cells((RowLooper - 1), 2).Value
ElseIf Right(Cells(RowLooper, 2), 5) = "Total" And Cells(RowLooper, 3) = "" Then
Cells(RowLooper, 1) = Cells((RowLooper - 1), 1).Value
Cells(RowLooper, 2).Font.FontStyle = "Bold"
ElseIf Cells(RowLooper, 1).Value = "" And Len(Cells(RowLooper, 2)) > 0 Then
Cells(RowLooper, 1) = Cells((RowLooper - 1), 1).Value
ElseIf Right(Cells(RowLooper, 1), 5) = "Total" And Cells(RowLooper, 3) = "" Then
Cells(RowLooper, 1).Font.FontStyle = "Bold"
End If
Next RowLooper
End Sub
I appreciate all help and suggestions.
I am trying to populate all rows of a sheet that is a result of a pasted pivot table. I have written some code in an effort to populate the cells but it overwrites or misses the key information. This task has turned out to be more challenging than I first imagined. Here is my code:
Private Sub PopulateEmptyCells()
Dim EndRow As Integer
Dim RowLooper As Integer
With ActiveSheet
EndRow = Cells(65536, 1).End(xlUp).Row
For RowLooper = 7 To EndRow
If Cells(RowLooper, 2).Value = "" Or Cells(RowLooper, 2).Value = "" Then
Cells(RowLooper, 1) = Cells((RowLooper - 1), 1).Value
Cells(RowLooper, 2) = Cells((RowLooper - 1), 2).Value
ElseIf Right(Cells(RowLooper, 2), 5) = "Total" And Cells(RowLooper, 3) = "" Then
Cells(RowLooper, 1) = Cells((RowLooper - 1), 1).Value
Cells(RowLooper, 2).Font.FontStyle = "Bold"
ElseIf Cells(RowLooper, 1).Value = "" And Len(Cells(RowLooper, 2)) > 0 Then
Cells(RowLooper, 1) = Cells((RowLooper - 1), 1).Value
ElseIf Right(Cells(RowLooper, 1), 5) = "Total" And Cells(RowLooper, 3) = "" Then
Cells(RowLooper, 1).Font.FontStyle = "Bold"
End If
Next RowLooper
End Sub
I appreciate all help and suggestions.