Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to move the cursor to a different cell on the same row

I have not written any macro in visual basic at all. I would like to write a
macro with the control key (ctrl r) that allows me to move the cursor to
column Y of the same row. For example, if my cursor is on row A12, the
activation of this macro should move the cursor to Y12. If my cursor is on
row A19, then the cursor should be moved to Y19. Any help is appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro to move the cursor to a different cell on the same row

This should do the trick

Sub MoveToYColumn()
Dim A As Range
Set A = ActiveCell
ActiveSheet.Cells(A.Row, 25).Select
End Sub

Assign a keyboard shortcut with Alt-F8 after you have paste the above code
into a module.

Matt Chen
Blue Ridge Telecom

"Ann Wong" wrote:

I have not written any macro in visual basic at all. I would like to write a
macro with the control key (ctrl r) that allows me to move the cursor to
column Y of the same row. For example, if my cursor is on row A12, the
activation of this macro should move the cursor to Y12. If my cursor is on
row A19, then the cursor should be moved to Y19. Any help is appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro to move the cursor to a different cell on the same row

One way:

First, see David McRitchie's "Getting Started with Macros":

http://www.mvps.org/dmcritchie/excel/getstarted.htm

Put this in a regular code module:

Public Sub MoveToColumnY()
Cells(ActiveCell.Row, 25).Activate
End Sub

In XL, choose Tools/Macros/Macro, select "MoveToColumnY" and click
Option. Enter r in the textbox.



In article ,
"Ann Wong" <Ann wrote:

I have not written any macro in visual basic at all. I would like to write a
macro with the control key (ctrl r) that allows me to move the cursor to
column Y of the same row. For example, if my cursor is on row A12, the
activation of this macro should move the cursor to Y12. If my cursor is on
row A19, then the cursor should be moved to Y19. Any help is appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Macro to move the cursor to a different cell on the same row

Hi Ann,

- Open the Visual Basic Editor: ALT+F11 or menu Tools Macros Visual
Basic Editor
- There, display the Project Explorer window: menu View Project Explorer
- Select the book where to store the macro (ibelieve the workbook you are
working on): it should be listed in the Project Explorer window. Double-CLick
it.
- Insert a code module: Insert Module. A blankl module should pop-up.
- Add the macro code: copy and paste the code bellow (macro is called
MoveCursorToColumnY) in the code module:

Sub MoveCursorToColumnY()
If Not ActiveCell Is Nothing Then
Range("Y" & ActiveCell.Row).Select
End If
End Sub

- Close the Visual Basic Editor and go back to Excel.
- Finally, to set up a shortcut key (ctrl+R here), do as if you were running
a macro : either click the Run Macro button or menu Tools Macros Macro...
The macro dialog pops-up.
- In the dialog, select the MoveCursorToColumnY macro and click the Options
button. There, you can set the shortcut key as you wish.
- Now, just try it.

Regards,
Sebastien


"Ann Wong" wrote:

I have not written any macro in visual basic at all. I would like to write a
macro with the control key (ctrl r) that allows me to move the cursor to
column Y of the same row. For example, if my cursor is on row A12, the
activation of this macro should move the cursor to Y12. If my cursor is on
row A19, then the cursor should be moved to Y19. Any help is appreciated.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Macro to move the cursor to a different cell on the same row

You're welcome, Ann.
I am glad i could help.
Sébastien

"Ann Wong" wrote:

Hi Sebastienm,

Thank you very much for your help. As a beginner creating Excel Macro, Your
detailed instructions certainly make it very easy for me to follow. It worked
after my first attempt. Thanks again

Best Regards
Ann

"sebastienm" wrote:

Hi Ann,

- Open the Visual Basic Editor: ALT+F11 or menu Tools Macros Visual
Basic Editor
- There, display the Project Explorer window: menu View Project Explorer
- Select the book where to store the macro (ibelieve the workbook you are
working on): it should be listed in the Project Explorer window. Double-CLick
it.
- Insert a code module: Insert Module. A blankl module should pop-up.
- Add the macro code: copy and paste the code bellow (macro is called
MoveCursorToColumnY) in the code module:

Sub MoveCursorToColumnY()
If Not ActiveCell Is Nothing Then
Range("Y" & ActiveCell.Row).Select
End If
End Sub

- Close the Visual Basic Editor and go back to Excel.
- Finally, to set up a shortcut key (ctrl+R here), do as if you were running
a macro : either click the Run Macro button or menu Tools Macros Macro...
The macro dialog pops-up.
- In the dialog, select the MoveCursorToColumnY macro and click the Options
button. There, you can set the shortcut key as you wish.
- Now, just try it.

Regards,
Sebastien


"Ann Wong" wrote:

I have not written any macro in visual basic at all. I would like to write a
macro with the control key (ctrl r) that allows me to move the cursor to
column Y of the same row. For example, if my cursor is on row A12, the
activation of this macro should move the cursor to Y12. If my cursor is on
row A19, then the cursor should be moved to Y19. Any help is appreciated.


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
move cursor in excle using macro fdibbins Excel Discussion (Misc queries) 6 December 8th 08 06:58 PM
macro to move cursor one cell right Kodak1993 New Users to Excel 3 September 23rd 08 02:00 AM
Visual basic macro move cursor down 1 cell Roger Excel Worksheet Functions 1 September 12th 06 08:09 PM
macro to move cursor Bob S[_2_] Excel Programming 4 January 15th 04 03:36 PM
need help with macro -move cursor down then home Ftca Excel Programming 5 October 16th 03 01:24 PM


All times are GMT +1. The time now is 06:25 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"