Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional Formatting - Inserting Rows | Excel Worksheet Functions | |||
Inserting Blank rows after every row upto 2500 rows | Excel Worksheet Functions | |||
Why is inserting rows throwing off my hidden rows | Excel Programming | |||
Inserting multiple rows in excel with data in consecutive rows | Excel Programming | |||
Conditional Formatting Reference / Inserting Rows | Excel Worksheet Functions |