#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default weird

Hello,
I have a table in excel97 in which data is entered
downwards in columns. I am trying to set it so that when
the bottom of one column is reached then the first cell of
the next column is automatically activated.

The code I've tried so far is below, but I get a weird
response in that the code executes when clicking any cell
on the sheet, even when the active cell is clearly not one
of the ones specified.

Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
Select Case ActiveCell
Case [a4] 'bottom of first column
[b1].Activate 'top of next column
Case [b4]
[c1].Activate
End Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default weird

The default property for a range object is the value
property. The statement "Activecell" returns the range
refering, of course, to the active cell. The statement
"Select Case ActiveCell", since it does not specify a
property, by default references the value property of the
active cell. The same for the [a4] and [b4] references. So
your code actually reads like:

Select Case ActiveCell.Value
Case [a4].Value 'Is the same as cell A4's value
[B1].Activate
Case [b4].Value 'Is the same as cell B4's value
[C1].Activate
End Select

Since the value in cell A4 is likely blank or non-numeric,
any time you select a blank or non-numeric cell it will
activate cell B1.

Suggested change:

Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
Select Case ActiveCell.Address
Case "$A$4" 'bottom of first column
[B1].Activate 'top of next column
Case "$B$4"
[C1].Activate
End Select
End Sub

Regards,
Greg


-----Original Message-----
Hello,
I have a table in excel97 in which data is entered
downwards in columns. I am trying to set it so that when
the bottom of one column is reached then the first cell

of
the next column is automatically activated.

The code I've tried so far is below, but I get a weird
response in that the code executes when clicking any cell
on the sheet, even when the active cell is clearly not

one
of the ones specified.

Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
Select Case ActiveCell
Case [a4] 'bottom of first column
[b1].Activate 'top of next column
Case [b4]
[c1].Activate
End Select
End Sub

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default weird

Thanks for explaining that. Makes sense and now works.
-----Original Message-----
The default property for a range object is the value
property. The statement "Activecell" returns the range
refering, of course, to the active cell. The statement
"Select Case ActiveCell", since it does not specify a
property, by default references the value property of the
active cell. The same for the [a4] and [b4] references.

So
your code actually reads like:

Select Case ActiveCell.Value
Case [a4].Value 'Is the same as cell A4's value
[B1].Activate
Case [b4].Value 'Is the same as cell B4's value
[C1].Activate
End Select

Since the value in cell A4 is likely blank or non-

numeric,
any time you select a blank or non-numeric cell it will
activate cell B1.

Suggested change:

Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
Select Case ActiveCell.Address
Case "$A$4" 'bottom of first column
[B1].Activate 'top of next column
Case "$B$4"
[C1].Activate
End Select
End Sub

Regards,
Greg


-----Original Message-----
Hello,
I have a table in excel97 in which data is entered
downwards in columns. I am trying to set it so that when
the bottom of one column is reached then the first cell

of
the next column is automatically activated.

The code I've tried so far is below, but I get a weird
response in that the code executes when clicking any

cell
on the sheet, even when the active cell is clearly not

one
of the ones specified.

Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
Select Case ActiveCell
Case [a4] 'bottom of first column
[b1].Activate 'top of next column
Case [b4]
[c1].Activate
End Select
End Sub

.

.

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
weird problem WarrenK Setting up and Configuration of Excel 0 June 5th 09 05:46 PM
Is this weird or what? Finance Guru Excel Worksheet Functions 8 August 15th 08 07:24 PM
WEIRD QUESTION Louise Excel Discussion (Misc queries) 4 September 23rd 06 12:07 AM
Weird problem Sue Excel Worksheet Functions 2 November 29th 05 12:10 PM
Weird jhill New Users to Excel 1 August 10th 05 04:48 PM


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

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

About Us

"It's about Microsoft Excel"