Shoutbox

excel - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: excel (/showthread.php?tid=89836)

excel by toddy on 03-23-2009 at 07:25 PM

whats the best way to do 'add 1', to a cell selected/highlighted? basically everytime i click(or paste if makes things easier) on any cell i want the new value to be 'old value+1', so that i don't keep having to look what number is already in there, and then increasing it manually


RE: excel by Spunky on 03-23-2009 at 08:01 PM

Use a VBA macro...

vb code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Target = Target + 1
End Sub


Obviously just add a few conditions if Target is column A for example and if Target <> "" :p

EDIT: A bit more in depth:

vb code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target <> "" And ActiveCell.Column = 1 And ActiveCell.Row < 50 Then
        Target = Target + 1
    End If
End Sub

ActiveCell.Column uses numbers to represent columns instead of letters so A = 1, B = 2 etc.
RE: excel by toddy on 03-23-2009 at 09:51 PM

knew i should have change my first post, want to be able to select multiple cells at once, have them all add 1.


RE: excel by Spunky on 03-24-2009 at 01:00 AM

Are all cells in the same column or row? It'd be easier if there was some sort of pattern


RE: excel by toddy on 03-24-2009 at 01:25 AM

quote:
Originally posted by Spunky
Are all cells in the same column or row? It'd be easier if there was some sort of pattern
no, quite random spread

well 8 colums, 18 rows, but could be any selection of the cells

edit:
altho could live with select the cells row by row if it makes it easier/possible
RE: excel by foaly on 03-24-2009 at 12:38 PM

It seams easier to make a hotkey,
Select the cells, press the hotkey en let the hotkey print Selection.Count to a specific cell...