I create a range using the UsedRange of the ActiveSheet and then select at random a cell within this range. After this (code not shown) it transfers whatever is in this cell to another cell outside of the used range. When ran again, the UsedRange is updated to the current used range instead of the original one. I thought declaring the variables as static at the beginning would lock the initial used range. Please advise.
Code:
Static row_min As Integer
Static row_max As Integer
Static col_min As Integer
Static col_max As Integer
Dim actv_row As Integer
Dim actv_col As Integer
Dim actv_cell As String
row_min = ActiveSheet.UsedRange.Row
row_max = row_min + ActiveSheet.UsedRange.Rows.Count - 1
col_min = ActiveSheet.UsedRange.Column
col_max = col_min + ActiveSheet.UsedRange.Columns.Count - 1
actv_row = Int((row_max - row_min + 1) * Rnd + row_min)
actv_col = Int((col_max - col_min + 1) * Rnd + col_min)
ActiveSheet.Cells(actv_row, actv_col).Select