Garryfragher
New Member
- Joined
- May 26, 2011
- Messages
- 3
Hi guys
Last weeks I've been a frequent guest of this forum, it has been of great help allready. But now I have a problem, I can't seem to figure out, and I haven't come across a similar thread in this forum or anyother site to solve my problem.
I would greatly appreciated any help! Here we go!
I have a column, with values similar as follows. (in fact it's the first column of a copy- paste values only of a pivottable. The adjacent columns contain the real values.)
"1"
"1"
"1"
"Total 1"
"2"
"2"
"Total 2"
"4"
"Total 4"
"6"
"6"
"6"
"6"
"6"
"Total 6"
"Endtotal"
I looking for a macro to cut the row containing the value "Total*" and paste it just above the corresponding values. For example: row with "total 6", is pasted just above the first "6".
I have allready this code:
In fact this code doesn't do anything. But the funy thing is, if I replace "Selection.Insert Shift:=xlDown" with "selection.font.bold = true", the correct rows are made bold. I'm close, but not there yet.
Any hints to put me back on the right track?
Tnx!
Last weeks I've been a frequent guest of this forum, it has been of great help allready. But now I have a problem, I can't seem to figure out, and I haven't come across a similar thread in this forum or anyother site to solve my problem.
I would greatly appreciated any help! Here we go!
I have a column, with values similar as follows. (in fact it's the first column of a copy- paste values only of a pivottable. The adjacent columns contain the real values.)
"1"
"1"
"1"
"Total 1"
"2"
"2"
"Total 2"
"4"
"Total 4"
"6"
"6"
"6"
"6"
"6"
"Total 6"
"Endtotal"
I looking for a macro to cut the row containing the value "Total*" and paste it just above the corresponding values. For example: row with "total 6", is pasted just above the first "6".
I have allready this code:
Code:
Dim i As Variant
For i = Range("A300").End(xlUp).Row To 4 Step -1
If Len(Cells(i, 1)) > 3 And Cells(i, 1).Value <> "Endtotal" Then
Cells(i, 1).Select
Rows(ActiveCell.Row).Cut
Do Until ActiveCell <> ActiveCell.Offset(-1, 0)
ActiveCell.Offset(-1, 0).Select
Loop
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(0, 0).EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-1, 0).Select
End If
Next i
End Sub
In fact this code doesn't do anything. But the funy thing is, if I replace "Selection.Insert Shift:=xlDown" with "selection.font.bold = true", the correct rows are made bold. I'm close, but not there yet.
Any hints to put me back on the right track?
Tnx!