Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default seperating data

I have a sheet with ( amongst other data) a column containing a series of
prices in ascending order.

I need code to seperate them into ranges such a £0-£4000, $4001 - £6000,
£6001-£8000 and so on to £20,000. I would like to insert three blank rows
after each range so that I can add summary information on each range into
these rows.

Can you help please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default seperating data

Assume you numbers are in column C and C1 contains a label.

Sub Insertrows()
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Cat1 = (Cells(lastrow, "C") - 1) \ 4000
For i = lastrow To 2 Step -1
Cat = (Cells(i, "C") - 1) \ 4000
If Cat < Cat1 Then
Cells(i + 1, 1).Resize(3).EntireRow.Insert
End If
Cat1 = Cat
Next
End Sub

--
Regards,
Tom Ogilvy


"Alan M" wrote:

I have a sheet with ( amongst other data) a column containing a series of
prices in ascending order.

I need code to seperate them into ranges such a £0-£4000, $4001 - £6000,
£6001-£8000 and so on to £20,000. I would like to insert three blank rows
after each range so that I can add summary information on each range into
these rows.

Can you help please?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default seperating data

Hi Tom,


Thanks for the help. The code you sent inserts rows below the 0-4000 range.
However I also need it torun throught the column of prices and insert rows
below the 4001-6000 prices, the 6001- 8000 prices and so on so I have several
rows of prices in each range separated by three blank rows.

"Tom Ogilvy" wrote:

Assume you numbers are in column C and C1 contains a label.

Sub Insertrows()
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Cat1 = (Cells(lastrow, "C") - 1) \ 4000
For i = lastrow To 2 Step -1
Cat = (Cells(i, "C") - 1) \ 4000
If Cat < Cat1 Then
Cells(i + 1, 1).Resize(3).EntireRow.Insert
End If
Cat1 = Cat
Next
End Sub

--
Regards,
Tom Ogilvy


"Alan M" wrote:

I have a sheet with ( amongst other data) a column containing a series of
prices in ascending order.

I need code to seperate them into ranges such a £0-£4000, $4001 - £6000,
£6001-£8000 and so on to £20,000. I would like to insert three blank rows
after each range so that I can add summary information on each range into
these rows.

Can you help please?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default seperating data

Sub Insertrows()
Dim lastrow As Long, Cat1 As Long
Dim Cat As Long
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Cat1 = (Cells(lastrow, "C") - 1) \ 2000
If Cat1 < 1 Then Cat1 = 1
For i = lastrow To 2 Step -1
Cat = (Cells(i, "C") - 1) \ 2000
If Cat < 1 Then Cat = 1
If Cat < Cat1 Then
Cells(i + 1, 1).Resize(3).EntireRow.Insert
End If
Cat1 = Cat
Next
End Sub

--
Regards,
Tom Ogilvy


"Alan M" wrote:

Hi Tom,


Thanks for the help. The code you sent inserts rows below the 0-4000 range.
However I also need it torun throught the column of prices and insert rows
below the 4001-6000 prices, the 6001- 8000 prices and so on so I have several
rows of prices in each range separated by three blank rows.

"Tom Ogilvy" wrote:

Assume you numbers are in column C and C1 contains a label.

Sub Insertrows()
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Cat1 = (Cells(lastrow, "C") - 1) \ 4000
For i = lastrow To 2 Step -1
Cat = (Cells(i, "C") - 1) \ 4000
If Cat < Cat1 Then
Cells(i + 1, 1).Resize(3).EntireRow.Insert
End If
Cat1 = Cat
Next
End Sub

--
Regards,
Tom Ogilvy


"Alan M" wrote:

I have a sheet with ( amongst other data) a column containing a series of
prices in ascending order.

I need code to seperate them into ranges such a £0-£4000, $4001 - £6000,
£6001-£8000 and so on to £20,000. I would like to insert three blank rows
after each range so that I can add summary information on each range into
these rows.

Can you help please?

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
Formula for seperating data eechris Excel Discussion (Misc queries) 2 January 27th 10 10:54 PM
Seperating Data From Lists JF[_2_] Excel Worksheet Functions 2 April 23rd 07 12:29 PM
Seperating data from one column into two columns cshivley Excel Programming 2 May 25th 06 04:10 AM
Seperating Data from a cell to a row DA@PD[_2_] Excel Programming 1 February 7th 06 04:25 PM
Seperating Data within cells Tennisgirl Excel Discussion (Misc queries) 2 July 12th 05 05:00 PM


All times are GMT +1. The time now is 04:58 PM.

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"