Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting conditional rows


Hi,
Am pretty new to VB programming and am faced with quiet a complex
problem.
Any help, pointers would be much appreciated.

I've a list of records sorted by one field.

I want to do the following.

1. Insert a row after change in value of that field
2. Calculate the sum of two other fields in that row.
3. Keep a loop until it reaches the end.

Thanks a lot


--
funbuntyus
------------------------------------------------------------------------
funbuntyus's Profile: http://www.excelforum.com/member.php...o&userid=34392
View this thread: http://www.excelforum.com/showthread...hreadid=541716

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default inserting conditional rows


funbuntyus wrote:

Hi,
Am pretty new to VB programming and am faced with quiet a complex
problem.
Any help, pointers would be much appreciated.

I've a list of records sorted by one field.

I want to do the following.

1. Insert a row after change in value of that field
2. Calculate the sum of two other fields in that row.
3. Keep a loop until it reaches the end.

Thanks a lot


--
funbuntyus
------------------------------------------------------------------------
funbuntyus's Profile: http://www.excelforum.com/member.php...o&userid=34392
View this thread: http://www.excelforum.com/showthread...hreadid=541716



Hi

I hope this will give you a start

Private Sub Worksheet_Change(ByVal Target As Range)
Static oldentry
newentry = Range("This is the cell that changes").Value
Application.EnableEvents = False

If newentry < oldentry Then
ActiveCell.EntireRow.Insert (xlDown)
' will insert a row under that chaged cell asuming you press enter
q = Application.CountIf(Rows(1), "<") + 1
' this is the number of entries in that row ,(XXX) is the row number
'the next lines you have to modify to the cells you want to add up
' I asumed here to be row A you want to add the values from and
calculate them in row B
For i = 1 To q
Cells(2, i) = Cells(1, i + 2) + Cells(1, i + 3)
Next i
End If
Application.EnableEvents = True
newentry = Range("This is the cell that changes").Value
oldentry = Range("This is the cell that changes").Value

End Sub

Cheers Christian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting conditional rows


Thanks Christian!
You got me started pretty well, it worked.

-adi


--
funbuntyus
------------------------------------------------------------------------
funbuntyus's Profile: http://www.excelforum.com/member.php...o&userid=34392
View this thread: http://www.excelforum.com/showthread...hreadid=541716

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
Conditional Formatting - Inserting Rows Danny Excel Worksheet Functions 1 March 2nd 10 09:39 PM
Inserting Blank rows after every row upto 2500 rows Manju Excel Worksheet Functions 8 August 22nd 06 12:54 PM
Why is inserting rows throwing off my hidden rows jgeniti[_2_] Excel Programming 4 March 9th 06 11:25 PM
Inserting multiple rows in excel with data in consecutive rows technotronic Excel Programming 2 October 20th 05 03:12 PM
Conditional Formatting Reference / Inserting Rows Werner Rohrmoser Excel Worksheet Functions 1 September 9th 05 02:27 PM


All times are GMT +1. The time now is 06:27 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"