Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Need Comments on Code

This code was working okay until I added some rows in the worksheet. No new
columns. On the seventh line, I have changed the Range numbers to the new
row numbers. What I need is the meaning of lines 15 through 22. I think I
need to adjust a value here somewhere so the formula in line 28 works on the
correct cells (cells with new addresses). Could someone please explain line
15 through 22? (I added the line numbers in the left margin for reference in
this thread.)

1 Private Sub Worksheet_Change(ByVal Target As Range)
2 Dim nRow As Long, nRow1 As Long
3 Dim dV As Double, dP As Double
4 Dim rDV As Range, rDP As Range
5 Dim rng As Range, rng1 As Range, rng2 As Range
6 On Error GoTo ErrHandler
7 Set rng = Intersect(Range("U:U,AD:AD,AM:AM,AV:AV"),
Range("20:31,53:64,86:97"))
8 With Target
9 If .Count 3 Then Exit Sub
10 If Intersect(.Cells, rng) Is Nothing Then Exit Sub
11 Set rng1 = Intersect(.Cells, rng)
12 If rng1.Count 1 Then Exit Sub
13 End With
14 Debug.Print rng1.Address, rng1.Parent.Cells(rng1.Column + 2).Address,
15 With rng1
16 Set rng2 = rng1.Parent.Cells(rng1.row, rng1.Column + 3)
17 nRow1 = Int((.row - 19) / 33)
18 nRow = Int(.Column - 21) / 9
19 Set rDV = Range("V11").Offset(nRow + 33 * nRow1, 0)
20 Set rDP = Range("P11").Offset(nRow + 33 * nRow1, 0)
21 dV = Range("V11").Offset(nRow + 33 * nRow1, 0).Value
22 dP = Range("P11").Offset(nRow + 33 * nRow1, 0).Value
23 'sStr = rng1.Address & " - " & rng2.Address & "-" & rDP.Address
& "-" & rDV.Address
24 'MsgBox sStr
25 Application.EnableEvents = False
26 If Not IsEmpty(rDV) And Not IsEmpty(rDP) Then
27 If dP - dV < 0 Then
28 rng2.Value = (.Value - dV) / (dP - dV)
29 End If
30 Else
31 MsgBox "Values Required for Target and Op Zero: Cells " &
rDP.Address(0, 0) _
32 & " and " & rDV.Address(0, 0)
33 rng1.MergeArea.ClearContents
34 End If
35 Application.EnableEvents = True
36 End With
37 ErrHandler:
38 Application.EnableEvents = True
39 End Sub

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
excel 2000 how to format the comments font all comments Delquestion Excel Discussion (Misc queries) 1 October 8th 09 02:19 PM
How do I color code comments in cells on Excel spreadsheet? LBH Excel Worksheet Functions 1 September 27th 09 05:04 PM
Code crashes after clearing comments L. Howard Kittle Excel Worksheet Functions 2 February 20th 06 04:54 AM
Shortcut way for indicating comments in block of code. Hari[_3_] Excel Programming 5 August 10th 04 01:49 AM
Comments on this code to FTP save, please? Pat Beck Excel Programming 0 August 15th 03 06:53 PM


All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"