sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
Hi,
I have the bit of code below that is referring to a range of filtered cells on another worksheet. I need to know if there is a way of setting this range without having to select or activate the worksheet called "LogDetails". Right now the value for the "Rng" comes up as nothing and I can't see why it would. If I let the code show the worksheet called "LogDetails" it will select the filtered range on that worksheet. Any help, much appreciated.
Thanks, SS
I have the bit of code below that is referring to a range of filtered cells on another worksheet. I need to know if there is a way of setting this range without having to select or activate the worksheet called "LogDetails". Right now the value for the "Rng" comes up as nothing and I can't see why it would. If I let the code show the worksheet called "LogDetails" it will select the filtered range on that worksheet. Any help, much appreciated.
Thanks, SS
VBA Code:
LR = Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Row
Sheets("LogDetails").Range("G1:N" & LR).SpecialCells(xlCellTypeVisible).Select
Set Rng = Sheets("LogDetails").Range("G1:N" & LR).Selection.SpecialCells(xlCellTypeVisible).Select
On Error GoTo 0
If Rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If