Also select the 5 cells to the right

VBAProIWish

Well-known Member
Joined
Jul 6, 2009
Messages
1,027
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have the code below that works great to select whatever is the first cell is but also want to select the 5 cells to the right


VBA Code:
Sub Select_1stRow_in_Filter()

Dim rFiltered As Range
 
With ActiveSheet.AutoFilter.Range
  Set rFiltered = .Resize(.Rows.count - 1).Offset(1).Columns(2).SpecialCells(xlCellTypeVisible)
End With
 
'first cell:
rFiltered.Cells(1, 1).Select    '< ALSO SELECT THE 5 CELLS AFTER THE SELECTED CELL


'I tried this but it didn't work...
'first cell:
rFiltered.Resize(.Columns.count + 5).Cells(1, 1).Select


End Sub


Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I figured it out!

VBA Code:
'first cell:
rFiltered.Cells(1, 1).Resize(, 5).Select 'THE MAGIC LINE!
 
Upvote 0

Forum statistics

Threads
1,215,181
Messages
6,123,513
Members
449,101
Latest member
mgro123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top