Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Alex Meyer   on Dec 18 In MS Office Category.

  
Question Answered By: Rae Fischer   on Dec 18

Not answering your actual question, but ...

> However, the situation is that I set  up the SelectionChange
> event to fire  only when the user  clicked in the first column  of the
> sheet, because it make the offsets so easy  to maintain
> systematically ...

You can take control of your columns in a different way. I'm assuming that
the cell that is clicked  is called Target in your event sub. Then

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim TargetRow As Integer: TargetRow = Target.Row
Cells(TargetRow, "F").Value = "xx"
End Sub

I.e. grab the row number from the target cell and use the column you want in
cells  call. My example puts an "xx" in column F of any row you click  in.

> That way, it was only a matter of counting  the
> columns to locate  the exact position  of the data  being changed.

For my way, there's no counting at all - just use the column's letter (or
letters).

If you want a group  of adjacent cells, then something like

Range(Cells(TargetRow, "J"), Cells(TargetRow, "L")).Value = "zz"

or

Range("J" & TargetRow & ":L" & TargetRow).Value = "zz"

can be useful - and still no counting.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on possible to change Protected Sheet error message? Or get search suggestion and latest updates.


Tagged: