View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Programmable Column Sequencing?

Hakyab,

I've been away and hense did not get back to this sooner. However, I think
you are confusing Worksheet_SelectionChange with Worksheet_Change. The code I
posted only fires if an actual change is made to the data in the cell. I
included the following to clarify this "if you are actually entering and/or
changing data on the worksheet"

I tested the code before posting.

--
Regards,

OssieMac


"Hakyab" wrote:

OssieMac, your code will surely render the workbook inoperable, as each
select statement will trigger the change event, resulting in an infinite loop.

May I offer a modification:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strCol As String
Static Recursed as Booelan
if recursed then exit sub
recursed = true


'Assign the column Alpha Id to variable
strCol = Split(Columns(Target.Column) _
.Address(, 0), ":")(1)

Select Case strCol
Case "A"
Cells(Target.Row, "D").Select

Case "B"
Cells(Target.Row, "E").Select

Case "C"
Cells(Target.Row, "K").Select

Case "AB"
Cells(Target.Row, "AZ").Select

End Select
recursed = false

End Sub

Best,