ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   shift and down keys in macro (https://www.excelbanter.com/excel-discussion-misc-queries/253504-shift-down-keys-macro.html)

cousinexcel

shift and down keys in macro
 
Hi,
I want to mark four cells.
How can I write shift+down+down+down in a macro.
(Then I say copy paste etc).
Thanks
Cousin Excel

Jacob Skaria

shift and down keys in macro
 
Activecell.Resize(4).Select
Activecell.Resize(4).Copy

OR starting from cell A1 copy 4 cells to the same sheet cell J1

Range("A1").Resize(4).Copy Range("J1")

--
Jacob


"CousinExcel" wrote:

Hi,
I want to mark four cells.
How can I write shift+down+down+down in a macro.
(Then I say copy paste etc).
Thanks
Cousin Excel


cousinexcel

shift and down keys in macro
 
Hi and thank you Jacob Skaria.
This was something new for me and thank you.
I still need to use shift and down keys.
I hope shift and down keys will solve my probem. There are filtered cells
and when I say things other than shift and down keys it is copying hidden
(filtered away) cells I believe but I need to copy only four cells I see on
screen after filtering.

"Jacob Skaria" wrote:

Activecell.Resize(4).Select
Activecell.Resize(4).Copy

OR starting from cell A1 copy 4 cells to the same sheet cell J1

Range("A1").Resize(4).Copy Range("J1")

--
Jacob


"CousinExcel" wrote:

Hi,
I want to mark four cells.
How can I write shift+down+down+down in a macro.
(Then I say copy paste etc).
Thanks
Cousin Excel


Don Guillett

shift and down keys in macro
 
This will find the last row in the active column

Sub shiftdowndowndown()
ar = ActiveCell.Row
ac = ActiveCell.Column
'MsgBox ac
lr = Cells(Rows.Count, ac).End(xlUp).Row
'MsgBox lr
Cells(ar, ac).Resize(lr).Copy
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"CousinExcel" wrote in message
...
Hi,
I want to mark four cells.
How can I write shift+down+down+down in a macro.
(Then I say copy paste etc).
Thanks
Cousin Excel




All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com