#1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Fill cells

Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Fill cells

Not sure if this is what you need or not but right-click the tab of
the sheet, hit View Code and paste this in the

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Target = Target.Value + 1
End Sub

--
Dan


On Sep 9, 2:05*pm, art wrote:
Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Fill cells

Thanks. But is there a way, to have the option to enter more then one. Or at
least that if I wnat to enter more then 1, then nothing should fill in? How
about a popup window?

"Dan R." wrote:

Not sure if this is what you need or not but right-click the tab of
the sheet, hit View Code and paste this in the

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Target = Target.Value + 1
End Sub

--
Dan


On Sep 9, 2:05 pm, art wrote:
Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Fill cells

Without a Mouse_Over or Cell_Click event I do not see a way to do this.

"art" wrote:

Thanks. But is there a way, to have the option to enter more then one. Or at
least that if I wnat to enter more then 1, then nothing should fill in? How
about a popup window?

"Dan R." wrote:

Not sure if this is what you need or not but right-click the tab of
the sheet, hit View Code and paste this in the

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Target = Target.Value + 1
End Sub

--
Dan


On Sep 9, 2:05 pm, art wrote:
Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.


  #5   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Fill cells

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)
If Target.Cells.Count 1 Then Exit Sub

Cancel = True 'stop pop up from showing
If IsNumeric(Target.Value) Then
Target.Value = Target.Value - 1
End If
End Sub



"Dan R." wrote:

Not sure if this is what you need or not but right-click the tab of
the sheet, hit View Code and paste this in the

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Target = Target.Value + 1
End Sub

--
Dan


On Sep 9, 2:05 pm, art wrote:
Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.




  #6   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Fill cells

I have the following VBA. BUt I would like to know how to make that when
right clicking it should not go less then zero. If I right click on a 1 then
it should turn empty.

"Dan R." wrote:

Not sure if this is what you need or not but right-click the tab of
the sheet, hit View Code and paste this in the

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Target = Target.Value + 1
End Sub

--
Dan


On Sep 9, 2:05 pm, art wrote:
Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Fill cells

I do not think this can be done as there is no Cell_Click method that I can
find.

"art" wrote:

Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.

  #8   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Fill cells

Thanks. How about this. Is it possible to make that when I click on a cell, a
form control box that has a macro should float near the cell? i want to make
the button that has a macro float to where the mouse is. Is it possible?

"Kent Prokopy" wrote:

I do not think this can be done as there is no Cell_Click method that I can
find.

"art" wrote:

Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Fill cells

This may not be a satisfactory solution because in order to select the cell
a second time you have move the selection away from the cell and then back
to it again. Anyway, here is the event procedure which will do this..

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
On Error GoTo FixMeUp
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If
FixMeUp:
Application.EnableEvents = True
End Sub

To install it, right click the page where you want this functionality,
select View Code from the popup menu that appears, and then copy/paste the
above code into the code window that appeared. Now, since you didn't say
which cell you wanted to have this functionality, I guessed at A1; if that
is wrong, just change the A1 in the If..Then statement to the cell address
of the cell you want for your incrementer. By the way, if you could live
with a double click to activate the incrementer, then use this code
instead...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Address(False, False) = "A1" Then
On Error GoTo FixMeUp
Cancel = True
Application.EnableEvents = False
Target.Value = Target.Value + 1
End If
FixMeUp:
Application.EnableEvents = True
End Sub

With this code, you don't have to move focus away from the cell and back
again... just keep double clicking and the value will advance.

--
Rick (MVP - Excel)


"art" wrote in message
...
Hello:

Is there a way that I can make through anyway (macro, VBA) that when I
select a cell, it should automatically fill in the number 1. and If I
select
the cell twice the cell should fill in the number 2. Any help would be
appriciated.


Reply
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill Cells Based On Cells In Another Sheet [email protected] Excel Worksheet Functions 1 May 31st 07 10:30 PM
Fill cells with color based on criteria in two cells AA Excel Worksheet Functions 2 January 2nd 06 11:29 PM
How do I fill (copy) nonadjacent cells to adjacent cells? BuckyGeorge Excel Discussion (Misc queries) 2 December 22nd 05 04:18 AM
create a fill in template to tab to fill in cells Excel-erator Excel Discussion (Misc queries) 2 July 6th 05 09:57 PM
HOW TO FORMATE CELLS TO COUNT CELLS WITH A FILL COLOR? Moore New Users to Excel 1 June 15th 05 06:41 PM


All times are GMT +1. The time now is 04:18 AM.

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"