View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Phil Hageman[_3_] Phil Hageman[_3_] is offline
external usenet poster
 
Posts: 160
Default Offset explained, Clear All Tried

Paul, thanks for your interest and response. The code
refers to "P" and "V" cell ranges in three places in this
worksheet, thus the offset.

I did as you said; Edit Clear All in X19 - still the
same outcome, no answers in the "X", "AG", "AP" or "AY"
cells.

Still trying to get it right.

Thanks, Phil

-----Original Message-----
Phil,

If it should always be using P10 & V10, I'm a bit

confused by the code:

dV = range("V10").Offset(nRow + 32 * nRow1, 0).Value
dP = range("P10").Offset(nRow + 32 * nRow1, 0).Value

Offset(row,column) is used to get an offset to a cell

(e.g.
Range("A1").Offset(2,1).Value would be the value in B3),

so the cells used
for dP and dV will change depending on the row/column

changed in the
worksheet.

It looks like these two lines could be changed to:

dV = range("V10").Value
dP = range("P10").Value

Also, try clearing all formatting from X19, and seeing

whether you still get
a blank.

Paul

"Phil Hageman"

wrote in message
...
Paul, thanks very much for your help - appreciate your
time. Before I go further, please know I am not a
programmer and a lot of this code I do not understand.
That said, the following:

i.) The space was added, which cleared a compile error.
ii.) .5, or 50%, is the correct answer - but I'm still
getting a blank in X19, and, #Div/0! when I make entries
in AD19 (error in AG19), AM19 (error in AP19), and AV19
(error in AY19). Seems like it is looking in the wrong
place for the divisor (thus a blank and #Div/0!)?. The
inputs were made in the correct order.
iii.) Could this be a clue - for AD19, AM19 and AV19, it
should not be looking in P42 or V42, rather, P10 and

V10.

Where next?

Thanks, Phil





-----Original Message-----
Phil,

A few things:

i) NotIntersect is missing a space. I assume this is a

typo.
ii) The code you supply does give a value in X19 -

provided the value in U19 is entered after the values in
P10 and V10 are entered. However, it gives a value of

0.5,
not 50.
iii) For the other columns (AD19, AM19 and AV19), it is

difficult to see
where the mistake is without seeing the spreadsheet.

E.g.
for a change in
AD19, it is looking for a value of dV in V42 and a

value
of dP in P42. If
these are present in the spreadsheet, the code should

work properly.

Hope this helps,
Paul

"Phil Hageman"

wrote in message
...
Excel 2000, code located in the worksheet code

object.

Testing the first of three parameter cases in this
worksheet code; columns P10:P13 (data entry cells),
V10:V13 (data entry cells), U19:U30 (data entry

cells),
and column X19:X30 (code results cells):

Entering the value 100 in cell P10, and the value 50

in
cell V10 sets up a case for entries in U19:U30.

After
entering the value 75 in cell U19, pressing enter,

the
code should calculate the value 50 for cell X19.

Instead,
there is no value entered in cell X19 (it is blank on
screen) and the cursor moves on to cell U20. No

error
messages.

Entering the value 75 in AD19 results in #Div/0! in
cell AG19, result should be 50.
Entering the value 75 in AM19 results in #Div/0! in
cell AP19, result should be 50.
Entering the value 75 in AV19 results in #Div/0! in
cell AY19, result should be 50.

Can someone help me correct this?

Option Explicit
Private Sub Worksheet_Change(ByVal Target As range)
Dim nRow As Long
Dim nRow1 As Long
Dim dV As Double
Dim dP As Double
Dim rng As range
Set rng = Intersect(range("U:U, AD:AD, AM:AM,

AV:AV"), _
range("19:30, 51:62, 83:94"))
With Target
If .Count 1 Then Exit Sub
If NotIntersect(.Cells, rng) Is Nothing Then
nRow1 = Int((.row - 19) / 32) (0, 1, 2 =

Row
group)
nRow = Int(.Column - 21) / 9 (0, 1, 2, 3 =

Column group)
dV = range("V10").Offset _
(nRow + 32 * nRow1, 0).Value (A value in

V10, V11, V12, V13,
V42, V43, ..., V77)
dP = range("P10").Offset _
(nRow + 32 * nRow1, 0).Value (A value in

P10, P11, P12, P13,
P42, P43, ..., P77)
Application.EnableEvents = False
.Offset(0, 3).Value = (.Value - dV) / (dP -

dV)
Application.EnableEvents = True
End If
End With
End Sub



.



.