LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default plus 1

On Jul 17, 6:14 am, alex wrote:
On Jul 17, 6:38 am, alex wrote:





On Jul 16, 3:44 pm, "Rick Rothstein \(MVP - VB\)"


wrote:
Thanks Rick for your help.
I also need to know what Sub you'd use, and if any arguments are
required...unless I'm misunderstanding where to place the code.


You can probably place it in the Worksheet Change event. Maybe like this...


Private Sub Worksheet_Change(ByVal Target As Range)
Dim CurrentEnableEventsStatus As Boolean
CurrentEnableEventsStatus = Application.EnableEvents
Application.EnableEvents = False
If Target.Column = 2 Then Target.Value = Target.Value + 1
Application.EnableEvents = CurrentEnableEventsStatus
End Sub


Rick


That worked Rick. Thanks for your time.


alex- Hide quoted text -


- Show quoted text -


I probably spoke too soon (before I had users test the code).
The code works well; however, I'm unable to copy and paste more than
one cell at a time, e.g., copy D1:D2 paste to B1:B2.
I'm also unable to delete any value that's entered into column B.
When I attempt to delete the column or paste as I've described above,
I get a run time error '13' Type Mismatch. Which has something to do
with:
Target.Value = Target.Value + 1- Hide quoted text -

- Show quoted text -


You can check to make sure that column 2 is in the range modified and
then process each row in the range .

To expand on Rick's Code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim CurrentEnableEventsStatus As Boolean
Dim trow As Long
CurrentEnableEventsStatus = Application.EnableEvents
Application.EnableEvents = False
If Target.Column <= 2 And Target.Column + Target.Columns.Count - 1
= 2 Then

For trow = Target.Row To Target.Row + Target.Rows.Count - 1
Cells(trow, 2) = Cells(trow, 2) + 1
Next
End If
Application.EnableEvents = CurrentEnableEventsStatus
End Sub


Peter

 
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



All times are GMT +1. The time now is 09:22 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"