ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selecting adjacent cells (https://www.excelbanter.com/excel-programming/354091-selecting-adjacent-cells.html)

tom m

selecting adjacent cells
 
I have searched help for the proper usage of cell commands but have not been
able to identify anything that allows me to select a cell, and by means of a
macro, select the adjacent cell and invoke an insertion macro I created.
It's the selection of the adjacent cell that is driving me crazy. On a macro
level scale of 1 to 10, with 1 being beginner, I am probably a two. I can
create some macros but nothing fancy. Thanks in advance for your help.

Tom M

Chip Pearson

selecting adjacent cells
 
Try something like

ActiveCell(1,2).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Tom M" <Tom wrote in message
...
I have searched help for the proper usage of cell commands but
have not been
able to identify anything that allows me to select a cell, and
by means of a
macro, select the adjacent cell and invoke an insertion macro I
created.
It's the selection of the adjacent cell that is driving me
crazy. On a macro
level scale of 1 to 10, with 1 being beginner, I am probably a
two. I can
create some macros but nothing fancy. Thanks in advance for
your help.

Tom M




Dave Peterson

selecting adjacent cells
 
You don't usually need to select a cell to work with it.

Option Explicit
sub testme()
dim myCell as range
set mycell = activesheet.range("b99") '<-- how do you find the cell to start

mycell.offset(0,1).select
'.offset(x,y) means go x rows (up or down or 0)
and y columns (left or right or 0)

.....your code
end sub






Tom M wrote:

I have searched help for the proper usage of cell commands but have not been
able to identify anything that allows me to select a cell, and by means of a
macro, select the adjacent cell and invoke an insertion macro I created.
It's the selection of the adjacent cell that is driving me crazy. On a macro
level scale of 1 to 10, with 1 being beginner, I am probably a two. I can
create some macros but nothing fancy. Thanks in advance for your help.

Tom M


--

Dave Peterson

Tom M

selecting adjacent cells
 
Thanks Chip. But all this does is move the cursor. Maybe it would help if I
provide more information. I have a lengthy list that I process daily. I
have 9 columns of data and have to match 2 of the rows to a third row. I
created a macro that inserts cells depending on how many rows I select. I
have to highlight or select the two columns I need to add cells to. This is
in liew of using the right click, insert, rows etc. The macro works well,
but it can still be improved on. What I would like to do is just leave my
cell pointer in one column and have a macro select the adjacent column to the
right (including the cell where my pointer is) and then insert cells. I hope
this is clearer. Think you can make it work?

Thanks

Tom M

"Chip Pearson" wrote:

Try something like

ActiveCell(1,2).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Tom M" <Tom wrote in message
...
I have searched help for the proper usage of cell commands but
have not been
able to identify anything that allows me to select a cell, and
by means of a
macro, select the adjacent cell and invoke an insertion macro I
created.
It's the selection of the adjacent cell that is driving me
crazy. On a macro
level scale of 1 to 10, with 1 being beginner, I am probably a
two. I can
create some macros but nothing fancy. Thanks in advance for
your help.

Tom M






All times are GMT +1. The time now is 11:17 PM.

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