Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Storing a Range in a Public Variable
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="SaeOngJeeMa, post: 6192046"] Hi, I have two questions: 1) Is there a way to store a Range in public variable an have it's scope and lifetime last until the workbook is closed? I'm trying to use the code below but the Range information is being lost. 2) Is there a way to set the range with having to activate the worksheet and select the cells? Thanks, Dean **************************** In the General Declarations section of one of my code modules: Public grngFSF As Range Sub in one of my code modules that runs on the ThisWorkbook Open event and also gets run again when rows of the worksheet are added or removed: Public Sub setWorksheetDataRanges() On Error GoTo Err_setWorksheetDataRanges With Worksheets("FSF") .Activate .Range(Cells(5, 1), ActiveCell.SpecialCells(xlLastCell)).Select Set grngFSF = Selection Cells(5, 1).Select End With Exit_setWorksheetDataRanges: Exit Sub Err_setWorksheetDataRanges: MsgBox "sub setWorksheetDataRanges " & Err.Description Resume Exit_setWorksheetDataRanges End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Storing a Range in a Public Variable
Top