Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try
Sub copylastcell() Sheets("mysheet").Range("a2").End(xlDown). _ End(xlToRight).Copy ActiveCell End Sub -- Don Guillett SalesAid Software "Gabe" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It keeps deleting the value in A2? I tried the sub by its self, and it
doesn't do anything? "Don Guillett" wrote: try Sub copylastcell() Sheets("mysheet").Range("a2").End(xlDown). _ End(xlToRight).Copy ActiveCell End Sub -- Don Guillett SalesAid Software "Gabe" wrote in message ... 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sure enough that worked! Awesome, thanks again for showing me that it would
of taken forever to figure that out. The USAF thanks you too Sébastien. "sebastienm" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Activate hyperlinks in multiple Excel cells? | Excel Worksheet Functions | |||
Hyperlink in cells....how to activate it with out a mouse | Excel Discussion (Misc queries) | |||
Workbook.Activate / Window.Activate problem | Excel Programming | |||
ACTIVATE CELLS | Excel Worksheet Functions | |||
Macro to activate all cells in a range | Excel Programming |