ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   visual basic with Excel- how to move cursor right (https://www.excelbanter.com/excel-programming/327905-visual-basic-excel-how-move-cursor-right.html)

countyworksheetthatfiguressickandvacatio

visual basic with Excel- how to move cursor right
 
I have a small Excel worksheet for which I have done a very short Visual
Basic program. I am not experienced at VB. Have looked through many books but
can find no answer. Is there a command I can use to move the cursor 3 columns
to the right? This seems to be a very basic thing to do in any spreadsheet,
but the answer eludes me. Any help? Please respond to .
Thanks.

K Dales[_2_]

visual basic with Excel- how to move cursor right
 
ActiveCell.Offset(0,3).Select

"countyworksheetthatfiguressickandvacatio" wrote:

I have a small Excel worksheet for which I have done a very short Visual
Basic program. I am not experienced at VB. Have looked through many books but
can find no answer. Is there a command I can use to move the cursor 3 columns
to the right? This seems to be a very basic thing to do in any spreadsheet,
but the answer eludes me. Any help? Please respond to .
Thanks.


George Nicholson[_2_]

visual basic with Excel- how to move cursor right
 
Well, if you really need to move the active cell (aircode):
MyCell.Offset(0,3).Activate
and then put a value into it (remember that you've just changed the active
cell):
ActiveCell.Value = "new value"

Keep in mind that you frequently don't need to activate or select cells
within VBA as you would if you were in the user interface, or anywhere near
as much as the macro recorder might lead you to believe. :-) You can usually
refer to ranges/cells and manipulate them without actually selecting them.
Since Selection & Activation have a performance hit, learning when you can
safely avoid them can be a valuable tool.
MyCell.Offset(0,3).Value = "new value"
fills the same value into the same cell as the first example, but without
any activation.

FYI, when used with a range, the Cells(row,column) property behaves similar
to Offset(row, column) except it is 1 based rather than zero based.
True: MyCell.Offset(0,0).Address = MyCell.Cells(1,1).Address =
MyCell.Address

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"countyworksheetthatfiguressickandvacatio"
<countyworksheetthatfiguressickandvacatio@discussi ons.microsoft.com wrote
in message ...
I have a small Excel worksheet for which I have done a very short Visual
Basic program. I am not experienced at VB. Have looked through many books
but
can find no answer. Is there a command I can use to move the cursor 3
columns
to the right? This seems to be a very basic thing to do in any
spreadsheet,
but the answer eludes me. Any help? Please respond to
.
Thanks.





All times are GMT +1. The time now is 06:27 PM.

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