Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KDJ KDJ is offline
external usenet poster
 
Posts: 19
Default Inserting 2 rows above a certain cell

I have a column with numbers that are sorted in ascending order e.g

1
1
1
3
3
3
7
7
7

The highest number possible is 8. I would like to insert a line above the
spot where the number changes. How can I do this?
--
Thanks very much. KDJ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Inserting 2 rows above a certain cell

In this case, one between last 3 and first 7? Or, 3-7 and 1-3?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KDJ" wrote in message
...
I have a column with numbers that are sorted in ascending order e.g

1
1
1
3
3
3
7
7
7

The highest number possible is 8. I would like to insert a line above the
spot where the number changes. How can I do this?
--
Thanks very much. KDJ


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Inserting 2 rows above a certain cell

Subject is at odds with the text!

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

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - 1 To 1 Step -1
If .Cells(i, TEST_COLUMN).Value < .Cells(i + 1,
TEST_COLUMN).Value Then
.Rows(i + 1).Insert
End If
Next i

End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"KDJ" wrote in message
...
I have a column with numbers that are sorted in ascending order e.g

1
1
1
3
3
3
7
7
7

The highest number possible is 8. I would like to insert a line above the
spot where the number changes. How can I do this?
--
Thanks very much. KDJ



  #4   Report Post  
Posted to microsoft.public.excel.programming
KDJ KDJ is offline
external usenet poster
 
Posts: 19
Default Inserting 2 rows above a certain cell

I realised the mistake after I posted. Sorry!! Momentary lapse of reason ...

Yes, I did mean insert 2 rows (lines) above the spot where the number
changes i.e. above the first time 3 appears and above the first time 7
appears.

Thank you!
KDJ


"Bob Phillips" wrote:

Subject is at odds with the text!

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

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - 1 To 1 Step -1
If .Cells(i, TEST_COLUMN).Value < .Cells(i + 1,
TEST_COLUMN).Value Then
.Rows(i + 1).Insert
End If
Next i

End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"KDJ" wrote in message
...
I have a column with numbers that are sorted in ascending order e.g

1
1
1
3
3
3
7
7
7

The highest number possible is 8. I would like to insert a line above the
spot where the number changes. How can I do this?
--
Thanks very much. KDJ




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Inserting 2 rows above a certain cell

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

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - 1 To 1 Step -1
If .Cells(i, TEST_COLUMN).Value < .Cells(i + 1, _
TEST_COLUMN).Value Then
.Rows(i + 1).Resize(2).Insert
End If
Next i

End With

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"KDJ" wrote in message
...
I realised the mistake after I posted. Sorry!! Momentary lapse of reason
...

Yes, I did mean insert 2 rows (lines) above the spot where the number
changes i.e. above the first time 3 appears and above the first time 7
appears.

Thank you!
KDJ


"Bob Phillips" wrote:

Subject is at odds with the text!

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

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - 1 To 1 Step -1
If .Cells(i, TEST_COLUMN).Value < .Cells(i + 1,
TEST_COLUMN).Value Then
.Rows(i + 1).Insert
End If
Next i

End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"KDJ" wrote in message
...
I have a column with numbers that are sorted in ascending order e.g

1
1
1
3
3
3
7
7
7

The highest number possible is 8. I would like to insert a line above
the
spot where the number changes. How can I do this?
--
Thanks very much. KDJ






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 rows while keeping cell contents the same JDNETTC Excel Discussion (Misc queries) 4 January 30th 08 11:34 PM
anchor comments to cell while inserting and deleting rows db55ford Excel Discussion (Misc queries) 1 June 17th 06 02:27 AM
Inserting rows on cell trigger AMK4[_29_] Excel Programming 0 February 1st 06 08:44 PM
Using absolute cell refernce and inserting rows ladyhawk Excel Worksheet Functions 10 December 13th 05 10:59 PM
Cell References When Inserting Rows officeplus215 Excel Discussion (Misc queries) 2 October 1st 05 02:00 AM


All times are GMT +1. The time now is 11:00 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"