Sub SelectAreaToCopy()
Dim rcode As ReturnCode
Dim StartSel As ScreenPoint 'Screen location to start the selection
Dim EndColPoint As ScreenPoint 'Screen location with the last column for the selection
Dim EndCol As Integer
Dim EndRowPoint As ScreenPoint 'Screen location with the last row for the selection
Dim EndRow As Integer
'Get starting point for the selection
Set StartSel = ThisScreen.SearchText4("Jan", 1, 1, ThisScreen.DisplayRows, ThisScreen.DisplayColumns, FindOptions_Forward, TextComparisonOption_IgnoreCase)
'Get the last column in the selection
Set EndColPoint = ThisScreen.SearchText4("Profit", 1, 1, ThisScreen.DisplayRows, ThisScreen.DisplayColumns, FindOptions_Forward, TextComparisonOption_IgnoreCase)
EndCol = EndColPoint.Column + Len("Profit")
'Get the last row in the selection
Set EndRowPoint = ThisScreen.SearchText4("Dec", 1, 1, ThisScreen.DisplayRows, ThisScreen.DisplayColumns, FindOptions_Forward, TextComparisonOption_IgnoreCase)
EndRow = EndRowPoint.Row
'Start the selection
ThisScreen.SetSelectionStartPos StartSel.Row, StartSel.Column
'Extend the selection to the last row and column
ThisScreen.ExtendSelectionRect EndRow, EndCol
'Copy the selection to the clipboard in XML format.
rcode = ThisScreen.Copy3(CopySourceOption_Selection, CopyFormatOption_AsXML)
'Remove the screen selection so th enext copy command doesn't use it
rcode = ThisScreen.ClearSelection
End Sub