Hello,
I would greatly appreciate how to get the current row and column in the spreadsheet based on the selected cell. I want to first validate that the user is in an appropriate column, then I want to input values into certain columns. I think I can accomplish this with the appropriate code to retrieve the row and column.
The VBA equivalent to ActiveCell.Row & Activecell.Column
Thank You
Simple retrieve Row and Column from selected cell
-
- Posts: 6
- Joined: Thu Apr 30, 2015 10:48 pm
Simple retrieve Row and Column from selected cell
Open Office 4.1 on Windows 7 / Ubuntu 14.04
Re: Simple retrieve Row and Column from selected cell
Get the address of current cell
viewtopic.php?t=33400
viewtopic.php?t=33400
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
-
- Posts: 6
- Joined: Thu Apr 30, 2015 10:48 pm
Re: Simple retrieve Row and Column from selected cell
Hi,
From the post it uses:
cell = ThisComponent.getCurrentSelection
column = cell.CellAddress.Column
row = cell.CellAddress.Row
These values do not output to a mesgbox. How do I know it's working and what do I compare it to for a value.
I want to select a cell, If that cell is in column F I want it to perform a function, else do not perform the function.
If it is in F I want to write values in Columns A and B in the same row.
IF column = "6" Then
msgbox "Correct Column"
Else
Msgbox "Not Correct"
End If
Sorry, there is not much explanation of the functions.
Thank you.
From the post it uses:
cell = ThisComponent.getCurrentSelection
column = cell.CellAddress.Column
row = cell.CellAddress.Row
These values do not output to a mesgbox. How do I know it's working and what do I compare it to for a value.
I want to select a cell, If that cell is in column F I want it to perform a function, else do not perform the function.
If it is in F I want to write values in Columns A and B in the same row.
IF column = "6" Then
msgbox "Correct Column"
Else
Msgbox "Not Correct"
End If
Sorry, there is not much explanation of the functions.
Thank you.
Open Office 4.1 on Windows 7 / Ubuntu 14.04
-
- Volunteer
- Posts: 1544
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Simple retrieve Row and Column from selected cell
These values do not output to a mesgbox.
Code: Select all
MsgBox "row = " & row + 1 & " column = " & Chr$(column + 65)
The column letter will fail to display the correct letter if you select a cell beyond column Z If needed a more complicated conversion could resolve that issue.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Volunteer
- Posts: 1544
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Simple retrieve Row and Column from selected cell
Based on the starting value of A = 0 your test should be
Code: Select all
IF column = 5 Then
msgbox "Correct Column"
Else
Msgbox "Not Correct"
End If
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Volunteer
- Posts: 1544
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Simple retrieve Row and Column from selected cell
One more thing, Section 15.2 of Andrew Pitonyak's book “OpenOffice.org Macros Explained” includes a discussion and code examples of how to convert spreadsheet cell addresses.
If you don't have that book it can be downloaded from
http://www.pitonyak.org/oo.php
If you don't have that book it can be downloaded from
http://www.pitonyak.org/oo.php
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11