Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think it works now. I just had to change the sheet name to the current
sheet name. Thanks :-) "Dave Peterson" wrote: Maybe you can just use the equivalent of Edit|Find to find the last one: Option Explicit Sub testme01() Dim myTypes As Variant Dim iCtr As Long Dim wks As Worksheet Dim FoundCell As Range myTypes = Array("SG1", "SG2", "SG3", "SG4") Set wks = Worksheets("sheet1") With wks.Range("H1").EntireColumn For iCtr = LBound(myTypes) To UBound(myTypes) Set FoundCell = .Cells.Find(what:=myTypes(iCtr), _ after:=.Cells(1), _ LookIn:=xlValues, _ lookat:=xlWhole, _ searchorder:=xlByRows, _ Searchdirection:=xlPrevious, _ MatchCase:=False) If FoundCell Is Nothing Then MsgBox myTypes(iCtr) & " wasn't found!" Else FoundCell.Offset(1, 0).Resize(24).EntireRow.Insert End If Next iCtr End With End Sub Janis wrote: Column H is a type field. It is SG1, SG2, SG3, SG4.... at the end of each group I need 24 rows. There is a runtime error on the line for If ActiveCell.Value = ActiveCell.value thanks, Private Sub PutARowIn() Dim rng As Range Dim cell As Range Set rng = Range(Range("H2"), Cells(Rows.Count, "H").End(xlUp)) rng.Select For Each cell In rng If ActiveCell.Value = ActiveCell.Offset(-1, 0).Value Then ActiveCell.Offset(1, 0).Select Else ActiveCell.EntireRow.Insert ActiveCell.Offset(2, 0).Select End If Next End Sub -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Group rows (or hide rows) like in MS Project | Excel Worksheet Functions | |||
group rows between blank rows | Excel Discussion (Misc queries) | |||
delete rows in excel by service date | Excel Programming | |||
Can a service account be embedded in Workbook so that by default the macros are run with service account credentials and not the user credentials??? | Excel Discussion (Misc queries) | |||
Difference between a Service Release and a Service Pack? | Excel Programming |