Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro to insert lines
I'm trying to write a marco to search for a certain value in column A. When
the value is found, I want to insert a blank line above it. Once this is done, I want to repeat the process for the entire worksheet. Here's the macro I wrote. The problem is that is keeps inserting the blank row at the top of the worksheet. It doesn't move to the next value. I'm not sure how to write the code for this. Sub PV1insertblank() ' ' PV1insertblank Macro ' Macro recorded 4/10/2009 by krauli20 ' ' Keyboard Shortcut: Ctrl+q ' ActiveCell.Columns("A:A").EntireColumn.Select Selection.Find(What:="PV1", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate ActiveCell.Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown Selection.Interior.ColorIndex = xlNone End Sub Sub Macro6() ' ' Macro6 Macro ' Macro recorded 4/10/2009 by krauli20 ' ' End Sub |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro to insert lines
Try this instead
Sub insertrows() For i = Cells(Rows.Count, "a").End(xlUp).Row To 2 Step -1 If UCase(Cells(i, 1)) = "PV1" Then Rows(i).Insert Next i -- Don Guillett Microsoft MVP Excel SalesAid Software "Linda" wrote in message ... I'm trying to write a marco to search for a certain value in column A. When the value is found, I want to insert a blank line above it. Once this is done, I want to repeat the process for the entire worksheet. Here's the macro I wrote. The problem is that is keeps inserting the blank row at the top of the worksheet. It doesn't move to the next value. I'm not sure how to write the code for this. Sub PV1insertblank() ' ' PV1insertblank Macro ' Macro recorded 4/10/2009 by krauli20 ' ' Keyboard Shortcut: Ctrl+q ' ActiveCell.Columns("A:A").EntireColumn.Select Selection.Find(What:="PV1", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate ActiveCell.Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown Selection.Interior.ColorIndex = xlNone End Sub Sub Macro6() ' ' Macro6 Macro ' Macro recorded 4/10/2009 by krauli20 ' ' End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro to insert lines for 3 sections | Excel Discussion (Misc queries) | |||
macro to insert blank line when lines sum to zero | Excel Discussion (Misc queries) | |||
insert lines | Excel Discussion (Misc queries) | |||
Macro to insert blank lines | Excel Discussion (Misc queries) | |||
Macro insert lines | Excel Discussion (Misc queries) |