Forum Discussion
What to use instead of Activecell.column?
Hello SergioSolimena ,
can you describe what you would like to achieve? Excel already has a built-in function to return the number of the column. In English Excel it is COLUMNL(). If you don't provide a parameter it will return the column number of the current column. If you use a cell reference, like =COLUMN(B2) it will return the column number of the referenced cell.
IngeborgHawighorst
thank you for your reply which unfortunately does not answer my question.
I give an example to be clearer.
Suppose you have entered values in some cells :, in this way:
A1 = 2;
A2 = 1; A3 = 1; A4 = 0, A5 = -1
B2 = MediaLuminanza ($ AB $ 1)
B3 = MediaLuminanza ($ A $ 1)
I would like the following results
B2 = (A2 A3) / 2 = 1
B3 = (A3 A4) /2=0.5
So if, later, in A1 I insert 3, I would like to get
B2 = (A2 A3 A4) / 3 = 2/3 = 0.67
B3 = (A3 A4 A5) / 3 = 0/3 = 0
Unfortunately, the MediaLuminanza
IngeborgHawighorst wrote:Hello SergioSolimena ,
can you describe what you would like to achieve? Excel already has a built-in function to return the number of the column. In English Excel it is COLUMNL(). If you don't provide a parameter it will return the column number of the current column. If you use a cell reference, like =COLUMN(B2) it will return the column number of the referenced cell.
function does not work automatically.
If instead I click on cell B2 I get the correct result, as well as if I click on B3.
The problem, in my opinion, is that Column and Row pass the correct values only if I click in the cell.
But obviously I would like Column and Row to automatically pass the values of the cells into which the MediaLuminanza function has been inserted, namely the values of cells B2 and B3.
In Modulo1 I wrote the following function:
"
‘Function MediaLuminanza (NPunti)
Dim Xmin As Integer, Xmax As Integer, RigaL As Integer, RigaF As Integer, ColF As Integer, Media As Double
'Initialize
RigaL = 2 'Row B
'Program
ColF = activecell.Column
RigaF = activecell.Row
Media = 0
For k = 1 To NPpoints
Media = Cells (RigaF - 1, ColF k - 1) + Media
Next k
MediaLuminanza = Media / NPunti
‘End Function