Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macro equivalent to arrow keys

What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular cell.
I want it to simply do the equivalent of end up no matter where end up might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default macro equivalent to arrow keys

Hi

Try this example that copy it to C22

SubTest()
Dim FindString As String
Dim Rng As Range
FindString = Application.WorksheetFunction.Max(Range("C13:C20") )
Set Rng = Range("C13:C20").Find(What:=FindString, _
After:=Range("C20"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Rng.Resize(1, 2).Copy Range("C22")
Else
MsgBox "Nothing found"
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Robinson" wrote in message ...
What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular cell.
I want it to simply do the equivalent of end up no matter where end up might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.



  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default macro equivalent to arrow keys


--
When you lose your mind, you free your life.


"Jim Robinson" wrote:

What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular cell.
I want it to simply do the equivalent of end up no matter where end up might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro equivalent to arrow keys

set rng1 = Range(rng,rng.End(xltoRight))

rng1.copy Destination:=worksheets(Sheet3").End(xlup).Offset( 1,0)

--
Regards,
Tom Ogilvy

"Jim Robinson" wrote in message
...
What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular

cell.
I want it to simply do the equivalent of end up no matter where end up

might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy

tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.



  #5   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default macro equivalent to arrow keys

oops sorry maybe i should put something in here. sorry

are you meaning you're having trouble finding the date to the right of the
cell containg tvalue? like this
nvalue = cells(rng.row,rng.column+1)

then to move the date just decide where to put it and use that variable...
or did i completely miss your point?

also to move to the end of a row of data use the end property eg.....

cells(1,1).end(xlToRight).select

will move you to the last column in the section containing data exactly as
if you had press ctrl + the right arrow key
ben






--
When you lose your mind, you free your life.


"Jim Robinson" wrote:

What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular cell.
I want it to simply do the equivalent of end up no matter where end up might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default macro equivalent to arrow keys

this would be something simple to add to your code. i am sure others with a
lot more experience will have shorter answers. but the offfset is what you
use to move like you ask. offset(r,c), where if r is positive, it moves the
cursor down, if it's negative, it moves it up. the same for the c, it moves
right or left


Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)
rng.Select
Selection.Offset(0, 1).Select
ActiveCell.Copy
Selection.Offset(0, 3).Select
ActiveSheet.Paste
--


Gary


"Jim Robinson" wrote in message
...
What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular
cell.
I want it to simply do the equivalent of end up no matter where end up
might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy
tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default macro equivalent to arrow keys


that's a .end(wldown) for example


you can type in
range("A1").end(xldown).select
if you want to select the last cell down in the A column

you also can select all the range by
range( range("A1"), range("A1").end(xldown)).select

this last line is better this way:
With Range("A1")
Range(.Cells(1), .End(xlDown)).Select
end with

because you write and call only once A1
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default macro equivalent to arrow keys

Thanks Ron. It worked, with a small modification.

"Ron de Bruin" wrote:

Hi

Try this example that copy it to C22

SubTest()
Dim FindString As String
Dim Rng As Range
FindString = Application.WorksheetFunction.Max(Range("C13:C20") )
Set Rng = Range("C13:C20").Find(What:=FindString, _
After:=Range("C20"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Rng.Resize(1, 2).Copy Range("C22")
Else
MsgBox "Nothing found"
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Robinson" wrote in message ...
What are the macro equivalent commands corresponding to the arrow keys (up
down left right) and to the "end" key?
Right now if I do the "record keystrokes" command for end up to take me up
to the last row with data, the recorded macro takes me to a particular cell.
I want it to simply do the equivalent of end up no matter where end up might
take me.

Here is what I am actually trying to do.

Dim rng As Range, tvalue
tvalue = WorksheetFunction.Max(Range("C13:C20"))
Set rng = Cells.Find(tvalue)

I find the max value (tvalue) in a range, then I set rng to be the cell
where that value is located. Now I want to go to that cell and copy tvalue
and the data in the cell to the right of tvalue to another location.

I have no problem determining tvalue or determining the cell location of
tvalue. Beyond that, I am stumped.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrow Keys Tim Excel Discussion (Misc queries) 1 January 24th 08 06:10 PM
Arrow Keys longfingers Excel Discussion (Misc queries) 2 September 14th 07 05:19 AM
arrow keys mpandis214 Excel Worksheet Functions 3 May 19th 07 05:43 PM
Arrow Keys sunnyjs321 Excel Discussion (Misc queries) 2 August 22nd 06 10:23 PM
how to use shift and down arrow keys in a macro? John W Excel Worksheet Functions 1 July 31st 05 01:21 AM


All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"