Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Insert Row After Series

I think this is possible but I'm not certain of the way the code would look.
I have an extract that comes to me in Excel format and I have a Macro that
runs through the Excel file reformatting it. The extract will have several
hundred rows.

Column I has a State description (I believe there are a couple dozen
descriptions) and what I need to do is add a blank row after each state.

Example ...

Pending
Pending
Pending
In Process
In Process
Active
Active
Active

would become

Pending
Pending
Pending

In Process
In Process

Active
Active
Active

I guess what I would like would be to add code to the existing Macro that
basically says everytime the value in column I changes add a row. Any ideas.

I hope this makes sense.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default Insert Row After Series

This goes through and looks at column A and inserts a row where there are
changes. Hope this helps!

Option Explicit
Sub insertrows()

Dim curselection As Range

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If curselection < curselection.Offset(1, 0) Then
curselection.Offset(1, 0).EntireRow.Insert
Set curselection = curselection.Offset(1, 0)
End If

Set curselection = curselection.Offset(1, 0)

Loop

End Sub
--
-SA


"FrankM" wrote:

I think this is possible but I'm not certain of the way the code would look.
I have an extract that comes to me in Excel format and I have a Macro that
runs through the Excel file reformatting it. The extract will have several
hundred rows.

Column I has a State description (I believe there are a couple dozen
descriptions) and what I need to do is add a blank row after each state.

Example ...

Pending
Pending
Pending
In Process
In Process
Active
Active
Active

would become

Pending
Pending
Pending

In Process
In Process

Active
Active
Active

I guess what I would like would be to add code to the existing Macro that
basically says everytime the value in column I changes add a row. Any ideas.

I hope this makes sense.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Insert Row After Series

That worked perfectly. Thank you so much. Is there a way to have the inserted
row have a background color ... say yellow maybe?

I tried modifying the line
curselection.Offset(1, 0).EntireRow.Insert
to include
Interior.ColorIndex = 41
so it was
curselection.Offset(1, 0).EntireRow.Insert.Interior.ColorIndex = 41
but I got an error, I'm not surprised. It was a long shot but I thought it
was worth trying. Any ideas would be great.

Thanks again.


"StumpedAgain" wrote:

This goes through and looks at column A and inserts a row where there are
changes. Hope this helps!

Option Explicit
Sub insertrows()

Dim curselection As Range

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If curselection < curselection.Offset(1, 0) Then
curselection.Offset(1, 0).EntireRow.Insert
Set curselection = curselection.Offset(1, 0)
End If

Set curselection = curselection.Offset(1, 0)

Loop

End Sub
--
-SA


"FrankM" wrote:

I think this is possible but I'm not certain of the way the code would look.
I have an extract that comes to me in Excel format and I have a Macro that
runs through the Excel file reformatting it. The extract will have several
hundred rows.

Column I has a State description (I believe there are a couple dozen
descriptions) and what I need to do is add a blank row after each state.

Example ...

Pending
Pending
Pending
In Process
In Process
Active
Active
Active

would become

Pending
Pending
Pending

In Process
In Process

Active
Active
Active

I guess what I would like would be to add code to the existing Macro that
basically says everytime the value in column I changes add a row. Any ideas.

I hope this makes sense.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default Insert Row After Series

You could do:

curselection.Offset(1, 0).EntireRow.Insert
curselection.Offset(1, 0).EntireRow.Select
Selection.Interior.ColorIndex = 41 '41 is blue yellow is 6
Set curselection = curselection.Offset(1, 0)

Hope this helps!
--
-SA


"FrankM" wrote:

That worked perfectly. Thank you so much. Is there a way to have the inserted
row have a background color ... say yellow maybe?

I tried modifying the line
curselection.Offset(1, 0).EntireRow.Insert
to include
Interior.ColorIndex = 41
so it was
curselection.Offset(1, 0).EntireRow.Insert.Interior.ColorIndex = 41
but I got an error, I'm not surprised. It was a long shot but I thought it
was worth trying. Any ideas would be great.

Thanks again.


"StumpedAgain" wrote:

This goes through and looks at column A and inserts a row where there are
changes. Hope this helps!

Option Explicit
Sub insertrows()

Dim curselection As Range

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If curselection < curselection.Offset(1, 0) Then
curselection.Offset(1, 0).EntireRow.Insert
Set curselection = curselection.Offset(1, 0)
End If

Set curselection = curselection.Offset(1, 0)

Loop

End Sub
--
-SA


"FrankM" wrote:

I think this is possible but I'm not certain of the way the code would look.
I have an extract that comes to me in Excel format and I have a Macro that
runs through the Excel file reformatting it. The extract will have several
hundred rows.

Column I has a State description (I believe there are a couple dozen
descriptions) and what I need to do is add a blank row after each state.

Example ...

Pending
Pending
Pending
In Process
In Process
Active
Active
Active

would become

Pending
Pending
Pending

In Process
In Process

Active
Active
Active

I guess what I would like would be to add code to the existing Macro that
basically says everytime the value in column I changes add a row. Any ideas.

I hope this makes sense.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Row After Series

Add this line...

curselection.Offset(1, 0).EntireRow.Interior.ColorIndex = 41

right after this line...

curselection.Offset(1, 0).EntireRow.Insert

although ColorIndex 41 is not yellow on my system (it's blue).

Rick


"FrankM" wrote in message
...
That worked perfectly. Thank you so much. Is there a way to have the
inserted
row have a background color ... say yellow maybe?

I tried modifying the line
curselection.Offset(1, 0).EntireRow.Insert
to include
Interior.ColorIndex = 41
so it was
curselection.Offset(1, 0).EntireRow.Insert.Interior.ColorIndex = 41
but I got an error, I'm not surprised. It was a long shot but I thought it
was worth trying. Any ideas would be great.

Thanks again.


"StumpedAgain" wrote:

This goes through and looks at column A and inserts a row where there are
changes. Hope this helps!

Option Explicit
Sub insertrows()

Dim curselection As Range

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If curselection < curselection.Offset(1, 0) Then
curselection.Offset(1, 0).EntireRow.Insert
Set curselection = curselection.Offset(1, 0)
End If

Set curselection = curselection.Offset(1, 0)

Loop

End Sub
--
-SA


"FrankM" wrote:

I think this is possible but I'm not certain of the way the code would
look.
I have an extract that comes to me in Excel format and I have a Macro
that
runs through the Excel file reformatting it. The extract will have
several
hundred rows.

Column I has a State description (I believe there are a couple dozen
descriptions) and what I need to do is add a blank row after each
state.

Example ...

Pending
Pending
Pending
In Process
In Process
Active
Active
Active

would become

Pending
Pending
Pending

In Process
In Process

Active
Active
Active

I guess what I would like would be to add code to the existing Macro
that
basically says everytime the value in column I changes add a row. Any
ideas.

I hope this makes sense.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Insert Row After Series

Thank you. Both Rick and SA you both helped me out quite a bit. I really
appreciate it.

Worked like a charm.

Yes I know the ColorIndex in my example was Blue not Yellow, I was just
picking random colors just for examples. Thank you for pointing me in the
right direction. I am very grateful.


"FrankM" wrote:

That worked perfectly. Thank you so much. Is there a way to have the inserted
row have a background color ... say yellow maybe?

I tried modifying the line
curselection.Offset(1, 0).EntireRow.Insert
to include
Interior.ColorIndex = 41
so it was
curselection.Offset(1, 0).EntireRow.Insert.Interior.ColorIndex = 41
but I got an error, I'm not surprised. It was a long shot but I thought it
was worth trying. Any ideas would be great.

Thanks again.


"StumpedAgain" wrote:

This goes through and looks at column A and inserts a row where there are
changes. Hope this helps!

Option Explicit
Sub insertrows()

Dim curselection As Range

Set curselection = Range("A1") 'or wherever you start

Do While curselection < ""

If curselection < curselection.Offset(1, 0) Then
curselection.Offset(1, 0).EntireRow.Insert
Set curselection = curselection.Offset(1, 0)
End If

Set curselection = curselection.Offset(1, 0)

Loop

End Sub
--
-SA


"FrankM" wrote:

I think this is possible but I'm not certain of the way the code would look.
I have an extract that comes to me in Excel format and I have a Macro that
runs through the Excel file reformatting it. The extract will have several
hundred rows.

Column I has a State description (I believe there are a couple dozen
descriptions) and what I need to do is add a blank row after each state.

Example ...

Pending
Pending
Pending
In Process
In Process
Active
Active
Active

would become

Pending
Pending
Pending

In Process
In Process

Active
Active
Active

I guess what I would like would be to add code to the existing Macro that
basically says everytime the value in column I changes add a row. Any ideas.

I hope this makes sense.

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
User Selectable Series and Number of Series for Line Chart Dave in NJ Charts and Charting in Excel 2 February 23rd 09 12:18 AM
Fill Series Dates: not letting me change the series from year to m Mike Excel Discussion (Misc queries) 1 January 24th 08 05:08 PM
Excel : insert new data series via mouse click on graphic. qpwe61 Charts and Charting in Excel 1 February 1st 07 11:56 AM
series graph -- one series being added to another series rich zielinski via OfficeKB.com Charts and Charting in Excel 3 March 30th 05 06:23 PM
Filling in a Date Series using the Fill | Series menu command Bob C Excel Programming 3 February 1st 05 11:13 PM


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