Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Move to a specific column in whatever row the cursor is currently

Good evening, all,

I'm writing a worksheet_change macr that will set a value in column V of the
target row if a change is made in any of the columns B to U.
So, if I make a change in any cell from A15 to U15, I want to select/goto
V15, and so on.
I have stored column V's column number to a variable ("AmendDate"), so that
if I insert/delete any columns, the code will work out where column V has
moved to.
I wrote a piece of code many moons ago that went something like:
Range("R" & target.row & "C" & AmendDate).select
but it doesn't work quite as I want it to... well, it doesn't work at all!
Can anyone suggest a line of code that will work with either the letter
reference of the column (in this case "V"), or ideally, using the column
number variable stored in "AmendDate"?

Thanks in advance for your help. :-)

Pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Move to a specific column in whatever row the cursor is currently

Columns B thru U:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r1 = Range("B:U")
If Intersect(t, r1) Is Nothing Then Exit Sub
Cells(t.Row, "V").Select
End Sub

Goes in the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200774


"PeteRooney" wrote:

Good evening, all,

I'm writing a worksheet_change macr that will set a value in column V of the
target row if a change is made in any of the columns B to U.
So, if I make a change in any cell from A15 to U15, I want to select/goto
V15, and so on.
I have stored column V's column number to a variable ("AmendDate"), so that
if I insert/delete any columns, the code will work out where column V has
moved to.
I wrote a piece of code many moons ago that went something like:
Range("R" & target.row & "C" & AmendDate).select
but it doesn't work quite as I want it to... well, it doesn't work at all!
Can anyone suggest a line of code that will work with either the letter
reference of the column (in this case "V"), or ideally, using the column
number variable stored in "AmendDate"?

Thanks in advance for your help. :-)

Pete

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Move to a specific column in whatever row the cursor is curre

Gary,

Thanks for this!

In the line:

Cells(t.Row, "V").Select

could I substitute the variable where I stored the column number of V? The
reason I ask it that if I insert/delete any columns before V, what is in V
won't be in V any more.

Thanks

Pete


"Gary''s Student" wrote:

Columns B thru U:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r1 = Range("B:U")
If Intersect(t, r1) Is Nothing Then Exit Sub


In the line:
End Sub

Goes in the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200774


"PeteRooney" wrote:

Good evening, all,

I'm writing a worksheet_change macr that will set a value in column V of the
target row if a change is made in any of the columns B to U.
So, if I make a change in any cell from A15 to U15, I want to select/goto
V15, and so on.
I have stored column V's column number to a variable ("AmendDate"), so that
if I insert/delete any columns, the code will work out where column V has
moved to.
I wrote a piece of code many moons ago that went something like:
Range("R" & target.row & "C" & AmendDate).select
but it doesn't work quite as I want it to... well, it doesn't work at all!
Can anyone suggest a line of code that will work with either the letter
reference of the column (in this case "V"), or ideally, using the column
number variable stored in "AmendDate"?

Thanks in advance for your help. :-)

Pete

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Move to a specific column in whatever row the cursor is curre

It doesn't matter, if T:U are deleted, V is still V, even though it was
previously X.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"PeteRooney" wrote in message
...
Gary,

Thanks for this!

In the line:

Cells(t.Row, "V").Select

could I substitute the variable where I stored the column number of V? The
reason I ask it that if I insert/delete any columns before V, what is in V
won't be in V any more.

Thanks

Pete


"Gary''s Student" wrote:

Columns B thru U:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r1 = Range("B:U")
If Intersect(t, r1) Is Nothing Then Exit Sub


In the line:
End Sub

Goes in the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200774


"PeteRooney" wrote:

Good evening, all,

I'm writing a worksheet_change macr that will set a value in column V
of the
target row if a change is made in any of the columns B to U.
So, if I make a change in any cell from A15 to U15, I want to
select/goto
V15, and so on.
I have stored column V's column number to a variable ("AmendDate"), so
that
if I insert/delete any columns, the code will work out where column V
has
moved to.
I wrote a piece of code many moons ago that went something like:
Range("R" & target.row & "C" & AmendDate).select
but it doesn't work quite as I want it to... well, it doesn't work at
all!
Can anyone suggest a line of code that will work with either the letter
reference of the column (in this case "V"), or ideally, using the
column
number variable stored in "AmendDate"?

Thanks in advance for your help. :-)

Pete



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Move to a specific column in whatever row the cursor is curre

Hello, Bob,

I already tried subsituting the variable for the label and it works.

I trap the column number to the variable using the column header, which has
a range name. This way, no matter where the column moves to the left or
right, I can always find exactly where it's gone to.

Thanks for your help!

Pete

"Bob Phillips" wrote:

It doesn't matter, if T:U are deleted, V is still V, even though it was
previously X.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"PeteRooney" wrote in message
...
Gary,

Thanks for this!

In the line:

Cells(t.Row, "V").Select

could I substitute the variable where I stored the column number of V? The
reason I ask it that if I insert/delete any columns before V, what is in V
won't be in V any more.

Thanks

Pete


"Gary''s Student" wrote:

Columns B thru U:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r1 = Range("B:U")
If Intersect(t, r1) Is Nothing Then Exit Sub


In the line:
End Sub

Goes in the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200774


"PeteRooney" wrote:

Good evening, all,

I'm writing a worksheet_change macr that will set a value in column V
of the
target row if a change is made in any of the columns B to U.
So, if I make a change in any cell from A15 to U15, I want to
select/goto
V15, and so on.
I have stored column V's column number to a variable ("AmendDate"), so
that
if I insert/delete any columns, the code will work out where column V
has
moved to.
I wrote a piece of code many moons ago that went something like:
Range("R" & target.row & "C" & AmendDate).select
but it doesn't work quite as I want it to... well, it doesn't work at
all!
Can anyone suggest a line of code that will work with either the letter
reference of the column (in this case "V"), or ideally, using the
column
number variable stored in "AmendDate"?

Thanks in advance for your help. :-)

Pete




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 to specific cell from a specific cell JSnow Excel Discussion (Misc queries) 4 August 29th 08 07:53 PM
need to move cursor to specific fields Cindy Excel Worksheet Functions 1 January 17th 08 11:59 PM
automatically move cursor to top of a column Jelena Excel Discussion (Misc queries) 3 August 24th 07 10:14 AM
how to move the cursor to column A after entering data column F tskaiser New Users to Excel 2 April 29th 06 02:28 PM
move cursor to 4th column with one press of tab key? Naveed Ahmad Purewal New Users to Excel 6 May 14th 05 04:22 AM


All times are GMT +1. The time now is 05:43 PM.

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"