Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to Insert Current Date into cell - Macro to "Save As" | Excel Worksheet Functions | |||
make a macro to insert a macro | Excel Discussion (Misc queries) | |||
Macro to insert copy and insert formulas only to next blank row | Excel Programming | |||
DO NOT Insert Row - Macro | Excel Worksheet Functions | |||
Insert Row Macro Help | Excel Programming |