PDA

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



PaSha
12-13-2007, 07:27 AM
i have one more question ... :cloud9:

in the code of the button i have UserForm1.Show

so the form shows up and executs it...

but after the i would plant this code: Range("i7").Value = Range("i7").Value +1

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 ..

Bob Phillips
12-13-2007, 07:32 AM
Put it in the OK button click event.

PaSha
12-13-2007, 07:35 AM
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 :(

PaSha
12-13-2007, 07:49 AM
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

PaSha
12-13-2007, 08:08 AM
hey xld, is it posible without doing it in the user form buttom ??

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

:mkay


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?

PaSha
12-13-2007, 08:42 AM
they all perform becouse they all think they are the callers

why is this so ???????


:bug: :bug:

Bob Phillips
12-13-2007, 08:46 AM
Unsure Pasha. Can you post the whole workbook with your current code?

And what are you trying to do again?

PaSha
12-13-2007, 09:08 AM
:( 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...
:( :(

PaSha
12-13-2007, 09:09 AM
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

PaSha
12-14-2007, 05:52 AM
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 ??

mikerickson
12-14-2007, 07:03 AM
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.

PaSha
12-14-2007, 08:26 AM
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 ...