Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Help! Insert a row in Macro

If cell A1 is not equal to cell A2, insert a row between A1 and A2. The same
logic applies to the whole Col. A. Any genius know how to write this
statement ????

Greatly Appreciate!!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Help! Insert a row in Macro

something like this:

Sub test()
Dim c As Range
For Each c In Application.Intersect(ActiveSheet.Range("A:A"),
ActiveSheet.UsedRange)
If c.Value < "" And c.Value = c.Offset(1, 0).Value Then
c.Offset(1, 0).EntireRow.Insert
End If
Next c
End Sub


--
Hope that helps.

Vergel Adriano


"MacroDummy" wrote:

If cell A1 is not equal to cell A2, insert a row between A1 and A2. The same
logic applies to the whole Col. A. Any genius know how to write this
statement ????

Greatly Appreciate!!!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Help! Insert a row in Macro

Hi Vergel,

what is "c"? do I need to select any cells first?

Many Thanks

"Vergel Adriano" wrote:

something like this:

Sub test()
Dim c As Range
For Each c In Application.Intersect(ActiveSheet.Range("A:A"),
ActiveSheet.UsedRange)
If c.Value < "" And c.Value = c.Offset(1, 0).Value Then
c.Offset(1, 0).EntireRow.Insert
End If
Next c
End Sub


--
Hope that helps.

Vergel Adriano


"MacroDummy" wrote:

If cell A1 is not equal to cell A2, insert a row between A1 and A2. The same
logic applies to the whole Col. A. Any genius know how to write this
statement ????

Greatly Appreciate!!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Help! Insert a row in Macro

Hi,

"c" is a range variable. The way it is used in the code, "c" will represent
one cell in Column A. The code takes the intersection of the used range in
the worksheet and column A. Then, it goes through each cell in column A and
compares it to the one below it. If they equal, a row is inserted between
them. You won't have to select any cell before running the macro.

--
Hope that helps.

Vergel Adriano


"MacroDummy" wrote:

Hi Vergel,

what is "c"? do I need to select any cells first?

Many Thanks

"Vergel Adriano" wrote:

something like this:

Sub test()
Dim c As Range
For Each c In Application.Intersect(ActiveSheet.Range("A:A"),
ActiveSheet.UsedRange)
If c.Value < "" And c.Value = c.Offset(1, 0).Value Then
c.Offset(1, 0).EntireRow.Insert
End If
Next c
End Sub


--
Hope that helps.

Vergel Adriano


"MacroDummy" wrote:

If cell A1 is not equal to cell A2, insert a row between A1 and A2. The same
logic applies to the whole Col. A. Any genius know how to write this
statement ????

Greatly Appreciate!!!!

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
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
make a macro to insert a macro mithu Excel Discussion (Misc queries) 6 March 20th 07 06:04 PM
Macro to insert copy and insert formulas only to next blank row bob Excel Programming 0 June 30th 06 12:02 PM
DO NOT Insert Row - Macro Danny Excel Worksheet Functions 4 May 5th 06 01:04 AM
Insert Row Macro Help ksp Excel Programming 2 January 16th 06 09:39 AM


All times are GMT +1. The time now is 01:14 PM.

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

About Us

"It's about Microsoft Excel"