Adding one to cell value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way, via a macro or some such, that I could add one to the value
of a cell by pushing a button or something, rather than having to manually
change the value?
 
Yes,

Sub Button1_Click()
With Sheet1 ' Changer to suit
..Select
If Range("A1").Value <> "" Then ' Change A1 to suit
Range("A1").Value = Range("A1").Value + 1
End If
End With
End Sub


Corey....

Is there a way, via a macro or some such, that I could add one to the value
of a cell by pushing a button or something, rather than having to manually
change the value?
 
Or you could try:
Sub Button1_Click()
With Sheet1
..Select
If activecell.Value <> "" Then
activecell.Value = activecell.Value + 1
End If
End With
End Sub

which will add (1) to the cell that is selected whent he forms button is pressed.

Corey....

Yes,

Sub Button1_Click()
With Sheet1 ' Changer to suit
..Select
If Range("A1").Value <> "" Then ' Change A1 to suit
Range("A1").Value = Range("A1").Value + 1
End If
End With
End Sub


Corey....

Is there a way, via a macro or some such, that I could add one to the value
of a cell by pushing a button or something, rather than having to manually
change the value?
 
I cannot get the macro to work. I can't say I'm really a macro expert. I
tried it using m as the form button, but it wouldn't work. If it's not too
much trouble, could someone explain the process? Microsoft Help didn't
really get it done for me...
 
1. Place a Forms Button on the worksheet
2. It will prompt you to set a macro to it
3. Selecte the NEW option
4. Between the Sub Button1_Click() and the End Sub place the code
With Sheet1
..Select
If activecell.value <>"" then
Activecell.value = Activecell.value + 1
end if
end with

Will look like:

Sub Button1_Click()
With Sheet1 ' Does the following with the Sheet selected
..Select ' Selects the Sheet above
If activecell.value <>"" then ' Check to see if the Cell that is selected has No Value in it, if No
Value then doe the following
Activecell.value = Activecell.value + 1 ' Changes the value of the ActiveCell to ADD 1 to the value
end if ' End of the IF statement (If ActiveCell is empty)
end with ' End of the With Statement (Sheet)
' Ends the SUB Routine
End Sub


Corey....



I cannot get the macro to work. I can't say I'm really a macro expert. I
tried it using m as the form button, but it wouldn't work. If it's not too
much trouble, could someone explain the process? Microsoft Help didn't
really get it done for me...
 
It keeps saying the ..Select thing is a syntax error. It's highlighted in
blue and the Sub Button1_Click() line is highlighted yellow. It also
sometimes says error: expected:case.
 
1. Make sure the Button name is correct, i used Button1, but this need not be the case if you
have more than 1 already

2. If you right click the button and select Asign Macro the code between the grey lines should have:
Sub Button1_Click()
With Sheet1
..Select
If ActiveCell.Value <> "" Then
ActiveCell.Value = ActiveCell.Value + 1
End If
End With
End Sub

3. Make sure there is only ONE fullstop in the line .Select

ctm

It keeps saying the ..Select thing is a syntax error. It's highlighted in
blue and the Sub Button1_Click() line is highlighted yellow. It also
sometimes says error: expected:case.
 
Sorry, might be my fault with the 2 x fullstops in the SELECT line.
There is ONLY one.

1. Make sure the Button name is correct, i used Button1, but this need not be the case if you
have more than 1 already

2. If you right click the button and select Asign Macro the code between the grey lines should have:
Sub Button1_Click()
With Sheet1
..Select
If ActiveCell.Value <> "" Then
ActiveCell.Value = ActiveCell.Value + 1
End If
End With
End Sub

3. Make sure there is only ONE fullstop in the line .Select

ctm

It keeps saying the ..Select thing is a syntax error. It's highlighted in
blue and the Sub Button1_Click() line is highlighted yellow. It also
sometimes says error: expected:case.
 
Thanks!!

Corey said:
Sorry, might be my fault with the 2 x fullstops in the SELECT line.
There is ONLY one.

1. Make sure the Button name is correct, i used Button1, but this need not be the case if you
have more than 1 already

2. If you right click the button and select Asign Macro the code between the grey lines should have:
Sub Button1_Click()
With Sheet1
..Select
If ActiveCell.Value <> "" Then
ActiveCell.Value = ActiveCell.Value + 1
End If
End With
End Sub

3. Make sure there is only ONE fullstop in the line .Select

ctm

It keeps saying the ..Select thing is a syntax error. It's highlighted in
blue and the Sub Button1_Click() line is highlighted yellow. It also
sometimes says error: expected:case.
 
Assuming the cell simply contains a number
Highlight the cell.
Press [F2]
enter +1
press [Home]
press equal [=] or plus [+]
press [Enter]

If the cell contains a formula, or if you have already done the above once:
Highlight the cell.
Press [F2]
enter +1
press [Enter]

________
Greg Stigers, MCSA
remember to vote for the answers you like
 
Back
Top