Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|