• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can you display the content of a selected row in a pop-up window?

skane2600

New Member
I have to work with a spreadsheet that has a lot of columns, so I have to scroll a lot to find what I'm looking for. It would be great to have a macro that would display the selected row in a pop-up window. The idea is that the window would display the row in a vertical format with column headings (e.g. Column Title1: Cell value <newline> Column Title2: Cell value). Can anyone give me a starting point for this macro?


I'm not an Excel expert, so if there's a built-in way to do this, I'd like to know that too. Thanks!
 
Hi, skane2600!


Perhaps you'd want to read the three green sticky posts at this forums main page so as to know the guidelines that will lead to know how this community operates (introducing yourself, posting files, netiquette rules, and so on).


Regards!
 
Hi ,


Copy the following code to whichever sheet you want to have this facility :

[pre]
Code:
Public Sub Display_row_contents()
Const NUMBER_OF_COLUMNS = 10   '  Change this as needed
Const STARTING_COLUMN = 3      '  Change this as needed
Const HEADER_ROW = 1           '  Change this as needed
Const MAX_TITLE_LENGTH = 20    '  Change this as needed

'  At present the display consists of the column title and the cell contents
'  If you want the cell addresses to be displayed , change the statement :
'     display_string = display_string & col_title & "   :   " & cell_val & vbCrLf
'  replacing col_title by cell_add to :
'     display_string = display_string & cell_add & "   :   " & cell_val & vbCrLf

Dim input_row As Range
Set input_row = Application.InputBox("Select the row whose contents you wish to display : ", , , , , , , 8)

display_string = ""
For i = STARTING_COLUMN To STARTING_COLUMN + NUMBER_OF_COLUMNS
cell_add = ActiveSheet.Cells(1, 1).Offset(input_row.Row - 1, i - 1).Address
cell_val = Range(cell_add).Value2
col_title = ActiveSheet.Cells(1, 1).Offset(HEADER_ROW - 1, i - 1).Value2
If col_title = "" Then col_title = "No Title"
If Len(col_title) < MAX_TITLE_LENGTH Then
col_title = col_title & Space(MAX_TITLE_LENGTH - Len(col_title))
End If
display_string = display_string & col_title & "   :   " & cell_val & vbCrLf
Next
MsgBox display_string
Set input_row = Nothing
End Sub
[/pre]
Narayan
 
@NARAYANK991

Hi!

Despite of the usefulness of having a the equivalent of a tooltip text box (or something alike as in other languages) I firstly thought about a new sheet with transposed data in columns A:B (title row and selected row respectively) and playing with windows panes arranged vertically.

Why that? because my first thought had been "how is he gonna go on working in that sheet?", and my second one "won't it be enough cumbersome to close the message box or the user form (ok, this might be modeless) to select another row and pressing again the key combinations for popping-up the macro?"... But lazy at this time of night I just thought, not as you who really worked.


But here are my two well intentioned cents. Unfinished and abandoned.

http://dl.dropbox.com/u/60558749/How%20can%20you%20display%20the%20content%20of%20a%20selected%20row%20in%20a%20pop-up%20window_%20%28for%20skane2600%20at%20chandoo.org%29.xlsm


Regards!
 
Thanks everyone for your help. One thing I didn't mention was that I simply want to read the content of a row, I don't need to modify it. The spreadsheet is just used for reference throughout the day and only one row needs to be referenced per visit to the spreadsheet. BTW, I read the posting guidelines and I'm not aware that I've violated any rules, but if somebody can identify which rule I broke, I would be careful to avoid it in the future. Thanks, again.
 
Hi, skane2600!

None broken as far as I could see. The suggestion was only to invite you to introduce yourself, know how to find articles here, how to post or upload, such kind of things.

Regards!
 
Back
Top