the answer to the question was that it is possible to read the selected area only from the active worksheet.
I don't know your goal, so my example might be pointless and not suitable for your use.
I added it here anyway.
The Workbook_SheetSelectionChange event enables the selections made after opening the workbook to be saved in a variable.
The Workbook_Open event enables saving worksheet selections to variables.
However, this is done by activating the worksheets one by one, so I don't know if this is of any use in your case.
When opening the workbook, the subprogram reads the Selection addresses of all worksheets into the dictionary.
After opening, the changes in the Selection worksheets are automatically updated in the dictionary.
Copy these to ThisWorkbook section:
VBA Code:
Private Sub Workbook_Open()
Call TS_SheetsUserSelection 'Calls a subroutine called "TS_SheetsUserSelection" from the modules section
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
dict(Sh.Name) = Target.Address ' Record changes made to selections on any worksheets
End Sub
Copy these to the empty Module section:
VBA Code:
Option Explicit
Global dict As Object 'Global (and static) variable to store selections.
Sub TS_SheetsUserSelection() ' Go through all the worksheets and save their "Selection" address in the dictionary.
On Error GoTo ErrHand: Application.EnableEvents = False: Application.Calculation = xlManual: Application.ScreenUpdating = False: Application.DisplayAlerts = False
Set dict = CreateObject("Scripting.Dictionary")
Dim iWS As Worksheet, CurrentWS As Worksheet: Set CurrentWS = ActiveSheet
For Each iWS In Worksheets
iWS.Activate ' Activating the worksheet
dict.Add iWS.Name, Selection.Address ' Add the worksheet name as the dictionary key and the selected range as the keys value
Next
ErrHand:
CurrentWS.Activate ' Return to the worksheet that was open when started
Application.EnableEvents = True: Application.Calculation = xlAutomatic: Application.ScreenUpdating = True: Application.DisplayAlerts = True: On Error GoTo 0
End Sub
Sub PrintSelections() ' Just for testing
Dim WsTMP As Worksheet
For Each WsTMP In Worksheets
Debug.Print WsTMP.Name & ": " & dict(WsTMP.Name) ' Print Worksheet name and selection address
Next
End Sub
Sub Fill_SheetsUserSelection() ' An example of using a dictionary
Dim ws As Worksheet, WorkSheetsName As String, Fills As String
' the name of the worksheet whose selection is filled
WorkSheetsName = "Sheet1"
' The text with which the selected area is filled
Fills = "TestFill"
Set ws = Worksheets(WorkSheetsName)
ws.Range(dict(ws.Name)).Value = Fills
End Sub
The subroutine is not fail-safe, for example renaming and deleting a sheet will still leave the data in the dictionary.
A very bad and burdensome quick fix is to add the end of ThisWorkbook section:
VBA Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object) ' Always go through all the worksheets when the worksheet is activated
Call TS_SheetsUserSelection
End Sub