Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default macro to Insert rows at every change in a column

hi,

I would like to know the Macro code for Inserting rows at every change
in a given column

Regards

Macro man

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default macro to Insert rows at every change in a column

MMan,

Try the macro below, based on column D. To change that, change the line

Set myRange = Range("D:D")

to reflect your actual desired column.

--
HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim myRow As Long
Dim StrtRow As Long
Dim myCol As Integer
Dim myRange As Range

Set myRange = Range("D:D")

myCol = myRange.Column
StrtRow = myRange(65536).End(xlUp).Row

For myRow = StrtRow To 2 Step -1
If Cells(myRow, myCol).Value < Cells(myRow - 1, myCol).Value Then
Cells(myRow, myCol).EntireRow.Insert
End If
Next myRow
End Sub



wrote in message ups.com...
hi,

I would like to know the Macro code for Inserting rows at every change
in a given column

Regards

Macro man



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default macro to Insert rows at every change in a column

Hi Bernie,

Thanks a lot for giving me this code. its great!!!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default macro to Insert rows at every change in a column

hi Bernie,

Can you pls give me the code for defining the range through Input box
for the code which you gave for "macro to Insert rows at every change
in a column".

Thanks

Macro Man

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default macro to Insert rows at every change in a column

Macro Man,

Set myRange = Application.InputBox(Prompt:="Select your range", Type:=8)

HTH,
Bernie
MS Excel MVP


wrote in message
oups.com...
hi Bernie,

Can you pls give me the code for defining the range through Input box
for the code which you gave for "macro to Insert rows at every change
in a column".

Thanks

Macro Man



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
insert rows in a worksheet that do not change adjoining rows craigandmel Excel Discussion (Misc queries) 2 April 29th 08 10:26 PM
Function to insert rows on a change in a cell Subhash Excel Discussion (Misc queries) 3 March 19th 08 04:35 AM
insert column, rows, grayed out, help? Gregory Zubal IT, Plymouth Technology Excel Discussion (Misc queries) 1 March 14th 08 09:07 AM
How to insert rows based on change in data Leoc Excel Worksheet Functions 2 January 23rd 08 10:12 PM
Macro - Insert&Label Column, if the labeled column doesn't exist Jeff[_43_] Excel Programming 1 December 15th 04 09:33 PM


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