T
Thunder
'In any column to the right of column "B", I want to add the value in
cell "A1"
'to the value in the current row of column "B"
'I would like not to have to pass the 2 input cells as arguments to the
function
'A1val is an absolute named range defined as: Sheet1!$A$1
'Bval is a relative named range defined as: Sheet1!$B1 (with the active
cell being in row 1 at the time of name definition)
'
'Type the following in Sheet1:
' A B C D E
'1 33 10 =A1val+Bval =Add1(A1val, Bval) =Add2()
'2 20 =A1val+Bval =Add1(A1val, Bval) =Add2()
'3 30 =A1val+Bval =Add1(A1val, Bval) =Add2()
'4 40 =A1val+Bval =Add1(A1val, Bval) =Add2()
'
'From this I get the following results:
' A B C D E
'1 100 10 110 110 110
'2 20 120 120 110
'3 30 130 130 110
'4 40 140 140 110
'
'I want to get the same result in columns C, D and E, but obviously
don't.
'It seems that the absolute named range and relative named range both
work for Columns C and D,
'but not for Add2() in Column E.
Function Add1(x, y)
Add1 = x + y
End Function
Function Add2()
Add2 = Range("A1val") + Range("Bval")
End Function
cell "A1"
'to the value in the current row of column "B"
'I would like not to have to pass the 2 input cells as arguments to the
function
'A1val is an absolute named range defined as: Sheet1!$A$1
'Bval is a relative named range defined as: Sheet1!$B1 (with the active
cell being in row 1 at the time of name definition)
'
'Type the following in Sheet1:
' A B C D E
'1 33 10 =A1val+Bval =Add1(A1val, Bval) =Add2()
'2 20 =A1val+Bval =Add1(A1val, Bval) =Add2()
'3 30 =A1val+Bval =Add1(A1val, Bval) =Add2()
'4 40 =A1val+Bval =Add1(A1val, Bval) =Add2()
'
'From this I get the following results:
' A B C D E
'1 100 10 110 110 110
'2 20 120 120 110
'3 30 130 130 110
'4 40 140 140 110
'
'I want to get the same result in columns C, D and E, but obviously
don't.
'It seems that the absolute named range and relative named range both
work for Columns C and D,
'but not for Add2() in Column E.
Function Add1(x, y)
Add1 = x + y
End Function
Function Add2()
Add2 = Range("A1val") + Range("Bval")
End Function