Consulting

Results 1 to 12 of 12

Thread: in sheet if in the userform button ok was clicked perofm action if not then no...

  1. #1
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location

    Exclamation in sheet if in the userform button ok was clicked perofm action if not then no...

    i have one more question ...

    in the code of the button i have [VBA]UserForm1.Show
    [/VBA]
    so the form shows up and executs it...

    but after the i would plant this code: [VBA]Range("i7").Value = Range("i7").Value +1
    [/VBA]
    but this peace of code should only perform if in the userform the button ok was clicked...if it was cancle or exite then not...

    how could i do this ??

    hope i don't bother to much with this ..
    I like to help others... but sometimes i also need help ...

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Put it in the OK button click event.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    i can't - to complicated to explain why... it is posible outside of the form ???

    becouse if i would paste the code in the userform ok button the button i know now which button called it but i don't know from which sheet ... so complicated
    I like to help others... but sometimes i also need help ...

  4. #4
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    ok let say sloved, lol...

    i took the code you pasted about CALLER ...

    so i can do it with that just name every button speical name...

    thanks
    I like to help others... but sometimes i also need help ...

  5. #5
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    hey xld, is it posible without doing it in the user form buttom ??

    becouse now it's everything in a mess...




    what i have done is this for ex.

    If Caller = ButtonPon1 Then
    Workbooks("blabla").Sheets("MON").Activate
    Worksheets("MON").Unprotect Password:="pass"
    Range("i7").Value = Range("i7").Value +1
    Worksheets("MON").protect Password:="pass"

    If Caller = ButtonPon2 Then
    Workbooks("blabla").Sheets("MON").Activate
    Worksheets("MON").Unprotect Password:="pass"
    Range("i8").Value = Range("i8").Value +1
    Worksheets("MON").protect Password:="pass"

    and so on ...

    but when i click OK in the user form ... it changes all values +1 not only for specific button :s ...

    oh man oh man ...

    can i do it some other way?
    I like to help others... but sometimes i also need help ...

  6. #6
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    they all perform becouse they all think they are the callers

    why is this so ???????


    I like to help others... but sometimes i also need help ...

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Unsure Pasha. Can you post the whole workbook with your current code?

    And what are you trying to do again?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    ok here are my workbooks ...

    in workbooks RuckstandEintrag1 you can see there are 6 sheets, for 6 days...

    every sheet has buttons for adding and removing values ... (products)

    what i want to make is this: if the user click on button Dodaj in sheet Ponedeljk - he has to write 3 values in there which are then put into workbook - Produktnumer... that is the easy part ... but i want that if that userform closes and the user put inside those values that those numers increase by +1 if the user didn't put in there those values then the numers wouldn't increase...

    so what i made till now... i changed in my sheet Ponedeljek-Montag like you said ... i made i user form1 and when a user clicked on a button that user was called and in the user form i made thos if statements so the program can now which valu to increase ... but now it increases all values...

    so, hope i explained it clearly enough...
    I like to help others... but sometimes i also need help ...

  9. #9
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    so here is the second workbook ... you need this ... here in this one those values which are beeing puted in userform are then pasted here in this one ...

    oh and the code for seeing the VBA project is : ihlas113
    I like to help others... but sometimes i also need help ...

  10. #10
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    is it posible to make it like so:

    userform1.show
    if userform1.commandbutton1 (was clicked) Then
    Range("?").Value = Range("?").Value + 1
    Unload userform1
    else
    exit sub
    end if



    something like this ... i tried everything but it didn't work maybe someone knows how it could work ??
    I like to help others... but sometimes i also need help ...

  11. #11
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    That will error on the unload userform1 line if the userform is unloaded by clicking on the corner x.

    You may be looking for ActiveSheet.

  12. #12
    VBAX Contributor PaSha's Avatar
    Joined
    Nov 2007
    Location
    Slovenia
    Posts
    104
    Location
    jap =) i know ... thanks for your help from the previous thread ... i managed it to work now ...

    so i can say case solved...

    thank to all ...
    I like to help others... but sometimes i also need help ...

Posting Permissions

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