Activate Cells
Hi,
This code would work better than the {DOWN} in your case ie dealing with
grouped rows:
'---------------------------------
Sub Macro1()
Dim rg As Range, rg2 As Range
Set rg = ActiveCell
'1 - get the bottom column starting at rg
Set rg2 = Range(rg, rg.Parent.Cells(rg.Parent.Rows.Count, rg.Column))
'visible cells only
Set rg2 = rg2.SpecialCells(xlCellTypeVisible)
'2 - get the bottom col starting just bellow rg
Set rg = Range(rg.Offset(1, 0), rg.Parent.Cells(rg.Parent.Rows.Count,
rg.Column))
'3 - intersect the 2 ranges and keep first cell
Set rg = Application.Intersect(rg, rg2).Cells(1)
rg.Select
End Sub
'-----------------------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
"Gabe" wrote:
Hello,
I am trying to use the following code but for some reason it isn't working?
Can you all try it and maybe tell me what I am doing wrong? Everything works
up until it is supposed to select the cells to the right. As you would if you
were to use Ctrl+Shift+Right Arrow keys. Once it goes down, how do you make
the current cell that it selects active?
Sub Macro1()
Sheets("Sheet1").Select
Range("A2").Activate
'
Application.SendKeys "{DOWN}"
'
Range(Selection, Selection.End(xlToRight)).Copy
End Sub
|