Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Inserting a blank line

I have a column sorted by cities and a column next to that with the numbers
that can be 5, 10, 15, 25 or 30. I need to insert a space between cities and
have a count how many 5s, 10s, 15s etc there are.

column A: column D:
Boston 30
Boston 15
Boston 5
Boston 15

(in column D) 5 1(in column E)
15 2
30 1

Detroit 10

10 1

Orlando 10
Orlando 10
Orlando 10

10 3
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Inserting a blank line

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long, j As Long
Dim LastRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = LastRow + 1 To 2 Step -1

If .Cells(i, "A").Value < .Cells(i - 1, "A").Value Then

For j = 30 To 5 Step -5

.Rows(i).Insert
.Cells(i, "D").Value = j
.Cells(i, "E").Formula = _
"=SUMPRODUCT(--(A1:A" & LastRow & "=""" & _
.Cells(i - 1, "A").Value & """),--(B1:B" &
LastRow & "=" & j & "))"
If .Cells(i, "E").Value = 0 Then Rows(i).Delete
Next j
End If
Next i

End With

End Sub

--
__________________________________
HTH

Bob

"Bob" wrote in message
...
I have a column sorted by cities and a column next to that with the numbers
that can be 5, 10, 15, 25 or 30. I need to insert a space between cities
and
have a count how many 5s, 10s, 15s etc there are.

column A: column D:
Boston 30
Boston 15
Boston 5
Boston 15

(in column D) 5 1(in column E)
15 2
30 1

Detroit 10

10 1

Orlando 10
Orlando 10
Orlando 10

10 3



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting a line S.C Excel Worksheet Functions 1 April 10th 07 08:28 AM
inserting a blank row mrselkoil Excel Discussion (Misc queries) 1 January 24th 07 09:18 PM
Help with inserting a blank line on condition microsatellite Excel Programming 1 May 1st 06 01:58 AM
How do you add a blank line automatically after the Subtotal line MVSD Guy Excel Worksheet Functions 0 April 20th 06 01:04 AM
Inserting a line.... Brady Snow[_2_] Excel Programming 1 July 13th 04 05:10 PM


All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"