L
Lee Jeffery
Excel 97 on WINNT.
I have a number of rows of data in a report where each row i
identified as part of a 'group' by the use of a 2 letter code in colum
A.
To make it easier to action the information contained in the report,
would like to insert a blank line between each group where the column
code is HA, then HB, HC, etc.
I found some code which I adapted to look for these values and insert
blank row but it gives me the run-time error on the line:
.Offset(1).EntireRow.Resize(.Value - 1).Insert
The whole code is below:
Sub InsertRows()
Dim i As Long
Dim LastRow As Long
Dim WS As Worksheet
Set WS = ActiveWorkbook.Sheets("Sheet1")
LastRow = WS.Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1
With WS.Cells(i, "A")
If .Value = "HA" Or .Value = "HB" Or .Value = "HC" Or .Value = "HE" O
.Value = "HF" _
Or .Value = "HG" Or .Value = "HJ" Or .Value = "HP" Or .Value = "HM
Then
.Offset(1).EntireRow.Resize(.Value - 1).Insert
End If
End With
Next i
End Sub
I would appreciate any suggestions over where I have gone wrong
please. I'm not very good at this!
While I'm asking, can someone steer me in the right direction fo
saving a file using a date, please? I can do this using today's dat
as "570 report " & Format(Now, "dd-mm-yyyy") & ".xls". I need to us
the end date of a period the report relates to which is every secon
Wednesday (the next one would be 28 July, 2004). Do I need to set u
some form of calendar lookup function?
Thanks in advance.
Lee.
It's cool in Tasmania
I have a number of rows of data in a report where each row i
identified as part of a 'group' by the use of a 2 letter code in colum
A.
To make it easier to action the information contained in the report,
would like to insert a blank line between each group where the column
code is HA, then HB, HC, etc.
I found some code which I adapted to look for these values and insert
blank row but it gives me the run-time error on the line:
.Offset(1).EntireRow.Resize(.Value - 1).Insert
The whole code is below:
Sub InsertRows()
Dim i As Long
Dim LastRow As Long
Dim WS As Worksheet
Set WS = ActiveWorkbook.Sheets("Sheet1")
LastRow = WS.Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1
With WS.Cells(i, "A")
If .Value = "HA" Or .Value = "HB" Or .Value = "HC" Or .Value = "HE" O
.Value = "HF" _
Or .Value = "HG" Or .Value = "HJ" Or .Value = "HP" Or .Value = "HM
Then
.Offset(1).EntireRow.Resize(.Value - 1).Insert
End If
End With
Next i
End Sub
I would appreciate any suggestions over where I have gone wrong
please. I'm not very good at this!
While I'm asking, can someone steer me in the right direction fo
saving a file using a date, please? I can do this using today's dat
as "570 report " & Format(Now, "dd-mm-yyyy") & ".xls". I need to us
the end date of a period the report relates to which is every secon
Wednesday (the next one would be 28 July, 2004). Do I need to set u
some form of calendar lookup function?
Thanks in advance.
Lee.
It's cool in Tasmania