I designed a UserForm in VBA that has a RefEdit control that helps users select input range. And for user's convenience, the initial default range in the RefEdit is set as ActiveCell.CurrentRegion. Normally, this works fine.
But there is a defect: if the user selects the whole columns as the address in the RefEdit, e.g., Sheet1!$A:$C, and the data block locates at Sheet1!$A$1:$C$10, my current program will throw an error message letting the user know that there is empty cell in the input range.
But the program should shrink back to Sheet1!$A$1:$C$10 without sending an error message (You may check on Data>Analysis>Data Analysis>Covariance and select some whole columns, then you will understand what I am talking about). Of course, if input range is a block rather than whole columns, my program should not do any shrinkage but should go on the validation and any further computation on that block. How do I accomplish this?
The address is set in this way,
' Select the current region
ActiveCell.CurrentRegion.Select
' Initialize RefEdit control
UF1.RE1.Text = ActiveWindow.RangeSelection.Address
UF1.RE1.SetFocus
UF1.Show