LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Inserting rows based on count

or two<vbg

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"chris" wrote in message
...
Yet another version:

Public Sub AddRws(Val as string, ColumnNum as integer)

Dim x, LstVal, y As Integer, Cnt As Integer, CbxVal As Integer, FrstVal As

String
CbxVal = CInt(Cbx.Value)
Range("A1").EntireRow.Insert
With ActiveSheet.Columns(ColumnNum)
.Cells(1).Select
Set x = .Find(What:=Val, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,

MatchCase:=True)
If Not x Is Nothing Then
Cnt = Cnt + 1
FrstVal = x.Address
Do
Set LstVal = x
Set x = .FindNext(x)
Cnt = Cnt + 1
Loop While Not x Is Nothing And x.Address < FrstVal
Cnt = Cnt - 1
If Cnt < CbxVal Then
Range(LstVal.Address).Offset(1, 0).Select
For y = 1 To CbxVal - Cnt
ActiveCell.EntireRow.Insert
Next
End If
End If
End With
Range("A1").EntireRow.Delete
End Sub



 
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
Count rows based on multiple criteria dmg Excel Worksheet Functions 3 February 4th 10 05:30 PM
need help please inserting multiple rows based on cell value then copying to data sheet [email protected] Excel Worksheet Functions 1 July 1st 07 08:44 PM
Return Frequently occuring Rows, based on COUNT Brooks Excel Worksheet Functions 4 April 27th 07 01:41 AM
Count rows based on multiple criteria Murph Excel Worksheet Functions 1 October 28th 04 07:13 AM
Inserting rows based on another cells value MikeT[_2_] Excel Programming 4 April 11th 04 10:08 PM


All times are GMT +1. The time now is 01:45 AM.

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"