ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scroll (https://www.excelbanter.com/excel-programming/417148-scroll.html)

Art

Scroll
 
Hello:

I have the following code to add numbers to a cell when double clicking. Is
it poosible to do the same thing instead of double clicking just by scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub



Otto Moehrbach[_2_]

Scroll
 
Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub




Art

Scroll
 
thats what I meant. Can you please give me the full code for that? (the
Worksheet_Change event macro).

Please let me know.

Thanks.



"Otto Moehrbach" wrote:

Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub





Art

Scroll
 
No. What I want to do is, when I select a cell for example A1, then nothing
should happen yet. But when I scroll up with the mouse then it should add a
number starting from one. The more I scroll, the higher the number should be.
And the same when I scroll down, the numbers should subtract.

Please let me know.

Thanks.



"Dave Peterson" wrote:

So each and everytime you select a cell--using the mouse or the keyboard, you
want to add one to that cell?

That doesn't seem like a good idea to me.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub

If you wanted to limit the change to a certain range (say column A), you could
use:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub





art wrote:

thats what I meant. Can you please give me the full code for that? (the
Worksheet_Change event macro).

Please let me know.

Thanks.

"Otto Moehrbach" wrote:

Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub





--

Dave Peterson


Dave Peterson

Scroll
 
There's nothing that fires when you scroll the worksheet.

If you don't really want to scroll the worksheet, but want to have a way to
adjust a value in the cell, you could add a scrollbar from the forms toolbar to
the worksheet. You could use that to change the value in the cell. (But this
won't be scrolling the worksheet.)



art wrote:

No. What I want to do is, when I select a cell for example A1, then nothing
should happen yet. But when I scroll up with the mouse then it should add a
number starting from one. The more I scroll, the higher the number should be.
And the same when I scroll down, the numbers should subtract.

Please let me know.

Thanks.

"Dave Peterson" wrote:

So each and everytime you select a cell--using the mouse or the keyboard, you
want to add one to that cell?

That doesn't seem like a good idea to me.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub

If you wanted to limit the change to a certain range (say column A), you could
use:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub





art wrote:

thats what I meant. Can you please give me the full code for that? (the
Worksheet_Change event macro).

Please let me know.

Thanks.

"Otto Moehrbach" wrote:

Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub





--

Dave Peterson


--

Dave Peterson

Art

Scroll
 
But then I need to always press on that scroll bar. It difies my whole
purpose. I need to make that the wheel from the mouse should atuomatically
scroll the bar to add numbers. I don't mind adding a scroll bar from the
activex forms, but I want that the scroll wheel from the mouse should trigger
it up or down.

Is it possible?




"Dave Peterson" wrote:

There's nothing that fires when you scroll the worksheet.

If you don't really want to scroll the worksheet, but want to have a way to
adjust a value in the cell, you could add a scrollbar from the forms toolbar to
the worksheet. You could use that to change the value in the cell. (But this
won't be scrolling the worksheet.)



art wrote:

No. What I want to do is, when I select a cell for example A1, then nothing
should happen yet. But when I scroll up with the mouse then it should add a
number starting from one. The more I scroll, the higher the number should be.
And the same when I scroll down, the numbers should subtract.

Please let me know.

Thanks.

"Dave Peterson" wrote:

So each and everytime you select a cell--using the mouse or the keyboard, you
want to add one to that cell?

That doesn't seem like a good idea to me.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub

If you wanted to limit the change to a certain range (say column A), you could
use:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub





art wrote:

thats what I meant. Can you please give me the full code for that? (the
Worksheet_Change event macro).

Please let me know.

Thanks.

"Otto Moehrbach" wrote:

Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub





--

Dave Peterson


--

Dave Peterson


Dave Peterson

Scroll
 
Not anything I can do.

art wrote:

But then I need to always press on that scroll bar. It difies my whole
purpose. I need to make that the wheel from the mouse should atuomatically
scroll the bar to add numbers. I don't mind adding a scroll bar from the
activex forms, but I want that the scroll wheel from the mouse should trigger
it up or down.

Is it possible?

"Dave Peterson" wrote:

There's nothing that fires when you scroll the worksheet.

If you don't really want to scroll the worksheet, but want to have a way to
adjust a value in the cell, you could add a scrollbar from the forms toolbar to
the worksheet. You could use that to change the value in the cell. (But this
won't be scrolling the worksheet.)



art wrote:

No. What I want to do is, when I select a cell for example A1, then nothing
should happen yet. But when I scroll up with the mouse then it should add a
number starting from one. The more I scroll, the higher the number should be.
And the same when I scroll down, the numbers should subtract.

Please let me know.

Thanks.

"Dave Peterson" wrote:

So each and everytime you select a cell--using the mouse or the keyboard, you
want to add one to that cell?

That doesn't seem like a good idea to me.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub

If you wanted to limit the change to a certain range (say column A), you could
use:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub





art wrote:

thats what I meant. Can you please give me the full code for that? (the
Worksheet_Change event macro).

Please let me know.

Thanks.

"Otto Moehrbach" wrote:

Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub





--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

Art

Scroll
 
thanks

"Dave Peterson" wrote:

Not anything I can do.

art wrote:

But then I need to always press on that scroll bar. It difies my whole
purpose. I need to make that the wheel from the mouse should atuomatically
scroll the bar to add numbers. I don't mind adding a scroll bar from the
activex forms, but I want that the scroll wheel from the mouse should trigger
it up or down.

Is it possible?

"Dave Peterson" wrote:

There's nothing that fires when you scroll the worksheet.

If you don't really want to scroll the worksheet, but want to have a way to
adjust a value in the cell, you could add a scrollbar from the forms toolbar to
the worksheet. You could use that to change the value in the cell. (But this
won't be scrolling the worksheet.)



art wrote:

No. What I want to do is, when I select a cell for example A1, then nothing
should happen yet. But when I scroll up with the mouse then it should add a
number starting from one. The more I scroll, the higher the number should be.
And the same when I scroll down, the numbers should subtract.

Please let me know.

Thanks.

"Dave Peterson" wrote:

So each and everytime you select a cell--using the mouse or the keyboard, you
want to add one to that cell?

That doesn't seem like a good idea to me.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub

If you wanted to limit the change to a certain range (say column A), you could
use:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If Target.Cells.Count 1 Then
Exit Sub
End If

On Error GoTo ErrHandler:
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If

ErrHandler:
Application.EnableEvents = True
End Sub





art wrote:

thats what I meant. Can you please give me the full code for that? (the
Worksheet_Change event macro).

Please let me know.

Thanks.

"Otto Moehrbach" wrote:

Excel must know what cell you want to use as the target cell. When you
simply scroll the mouse wheel, what cell do you want Excel to use? Excel
doesn't know either. You can do what you want by simply selecting the cell
(click on the cell) and using a Worksheet_Change event macro. HTH Otto
"art" wrote in message
...
Hello:

I have the following code to add numbers to a cell when double clicking.
Is
it poosible to do the same thing instead of double clicking just by
scrolling
the scroll button on the mouse?

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True 'stop pop up from showing
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub





--

Dave Peterson


--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com