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