+ Reply to Thread
Results 1 to 16 of 16

Changing cell data by just clicking on it...

  1. #1
    Registered User
    Join Date
    04-06-2007
    Posts
    16

    Changing cell data by just clicking on it...

    Hey guys,

    i have made (found) a way to change the data in a cell by clicking on it, however i can only make it go from 1 to 0 or 0 to 1...heres the VB code:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If (ActiveCell.Value = 1) Then
    ActiveCell.Value = ""
    Else:
    If (ActiveCell.Value = "") Then
    ActiveCell.Value = 1
    End If
    End If
    End Sub
    however, i would like the code to do a different task, i would like it to add one to the number everytime you click on it...i.e. it goes from 1 to 2 to 3 to 4 to 5 etc. everytime you click on it...

    if it is possible, i would also like it to be restricted to a few cells, which i can determine afterwards and change

    Thnx
    Mayhs

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Prehaps this link would help

    http://www.mcgimpsey.com/excel/accumulator.html

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487
    Hi,
    Please Login or Register  to view this content.
    you can use

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    thnx...i tried them both and they didnt seem to work

    ...could you write a general one please, that works on all the cells (doesnt have a range like the ones posted above)...like the first one i posted but make it add one all the time? thnx

    Thnx
    Mayhs

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487
    Hi,


    What do you mean they don't seem to work??


    here's a macro


    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    Hi again, thanks for the help

    when i inputted the code you gave me into VB editor for a worksheet i saved it and then i went back to that worksheet and i clicked on the cell and it just set the target to 0.

    i cant use a macro, because im updating multiple items at different times, namely stock items and it would be impratcial having a macro for each stock item, as there are 40

    if you could try out the code i gave in my first post, i would like something similar, where you just click on the cell and the number goes up

    Thnx
    Mayhs

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487
    Here you go

    Please Login or Register  to view this content.
    You threw me off with "Just click on the cell" because selection change doesn't work like that

  8. #8
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    Quote Originally Posted by davesexcel
    Here you go

    Please Login or Register  to view this content.
    You threw me off with "Just click on the cell" because selection change doesn't work like that
    PERFECT! THANKS!!

    thanks for your time and effort...youll be seeing a lot of me around here lol:p

    Thnx
    Mayhs

  9. #9
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    sorry a quick question...how would i edit the code if i wanted to give it a range, for example from E19:E42?

    Thnx
    Mayhs

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487
    Quote Originally Posted by Mayhs
    sorry a quick question...how would i edit the code if i wanted to give it a range, for example from E19:E42?

    Thnx
    Mayhs
    This should work for you


    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    ahh dave that code doesnt work!

    i dont know why it isnt but the code you gave me previously is working...

  12. #12
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487
    Quote Originally Posted by Mayhs
    ahh dave that code doesnt work!

    i dont know why it isnt but the code you gave me previously is working...


    works for me, what doesn't work for you

    I said before, the selection change doesn't work if you just click on the cell if you are already on the cell, that's why I suggested a double click event

    What are you doing to require this auto numbering system ?

  13. #13
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    im updating stock items...

    its a software im creating for my cousin...it is a simulation of using a upc scanner in his retail business

    so clicking on the cell will be like scanning

    one sec ill try it on a plain worksheet...but its not working on my real software right now

  14. #14
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    ok...just checked and its working on a plain worksheet

    but in my real worksheet, the cells are merged (e is merged with f)...i think thats what might be causing it now to work?

    yeah just checked...i unmerged the cells and its working but i need the cells to be merged...

  15. #15
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487
    Quote Originally Posted by Mayhs
    ok...just checked and its working on a plain worksheet

    but in my real worksheet, the cells are merged (e is merged with f)...i think thats what might be causing it now to work?

    yeah just checked...i unmerged the cells and its working but i need the cells to be merged...
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    04-06-2007
    Posts
    16
    Thanks

    i nearly had a heart attack lol

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1