Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet_Change(ByVal Target As Range) - Big Problems
I just "discovered" this by accident a few weeks ago.
Have LOTS of application for it - but having problems setting it up. Situation: Have Five Groups. The First Line of Each Group will have the "trigger" in Cell E? Each Group has range name for complete group. If group 1 selected, the "undo" instructions of group 2 seem to void what the original selection was trying to do. Is there a way to get around this? If Range("FBSMINT") 0 Then ' "trigger" cell Call FLBIN_SMI_H ' This hides the group 2, 3, 4, and 5 ranges Else If Range("FBSMINT") = 0 Then ' "trigger" cell, again Call FLBIN_SMI_UH 'This Unhides the group 2, 3, 4 and 5 Ranges End If End If If Range("FBSAINT") 0 Then Call FLBIN_SAI_H ' This hides group 1, 3, 4 and 5 ranges Else If Range("FBSAINT") = 0 Then Call FLBIN_SAI_UH ' This Unhides group 1, 3, 4 and 5 Ranges End If End If Therefore, If group 1 is selected, the Unhide instructions in group 2 undo, what group 1 is trying to do. However, I do need some whay of "unhiding" in case of a mistake or change of mind. End Result : As various selections are made within the various groupings on the contract templates, the template will shorten considerably, making it much easier to view and work with, by the salesmen. I hope my attempted explanations are not too convoluted. As you can see, I have no problem utilizing standard modules together with the worksheet module - I think it actually helps keep things clearer. I sure hope someone can help me with this. I'm very excited about what I see as the possibilities for this application. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet_Change(ByVal Target As Range) - Big Problems
Your explanation of what you need to happen and under what circumstances is
not entirely clear to me. Does this, by any chance, do what you want? If Range("FBSMINT") 0 Then Call FLBIN_SMI_H ElseIf Range("FBSMINT") = 0 Then Call FLBIN_SMI_UH ElseIf Range("FBSAINT") 0 Then Call FLBIN_SAI_H ElseIf Range("FBSAINT") = 0 Then Call FLBIN_SAI_UH End If -- Rick (MVP - Excel) "BEEJAY" wrote in message ... I just "discovered" this by accident a few weeks ago. Have LOTS of application for it - but having problems setting it up. Situation: Have Five Groups. The First Line of Each Group will have the "trigger" in Cell E? Each Group has range name for complete group. If group 1 selected, the "undo" instructions of group 2 seem to void what the original selection was trying to do. Is there a way to get around this? If Range("FBSMINT") 0 Then ' "trigger" cell Call FLBIN_SMI_H ' This hides the group 2, 3, 4, and 5 ranges Else If Range("FBSMINT") = 0 Then ' "trigger" cell, again Call FLBIN_SMI_UH 'This Unhides the group 2, 3, 4 and 5 Ranges End If End If If Range("FBSAINT") 0 Then Call FLBIN_SAI_H ' This hides group 1, 3, 4 and 5 ranges Else If Range("FBSAINT") = 0 Then Call FLBIN_SAI_UH ' This Unhides group 1, 3, 4 and 5 Ranges End If End If Therefore, If group 1 is selected, the Unhide instructions in group 2 undo, what group 1 is trying to do. However, I do need some whay of "unhiding" in case of a mistake or change of mind. End Result : As various selections are made within the various groupings on the contract templates, the template will shorten considerably, making it much easier to view and work with, by the salesmen. I hope my attempted explanations are not too convoluted. As you can see, I have no problem utilizing standard modules together with the worksheet module - I think it actually helps keep things clearer. I sure hope someone can help me with this. I'm very excited about what I see as the possibilities for this application. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet_Change(ByVal Target As Range) - Big Problems
I suspect when you change something on your worksheet with code, it's
triggering the worksheet change event again, but for a different group of cells. You may want to try Application.EnableEvents = FALSE 'at the beginning Application.EnableEvents = TRUE 'at the end -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "BEEJAY" wrote: I just "discovered" this by accident a few weeks ago. Have LOTS of application for it - but having problems setting it up. Situation: Have Five Groups. The First Line of Each Group will have the "trigger" in Cell E? Each Group has range name for complete group. If group 1 selected, the "undo" instructions of group 2 seem to void what the original selection was trying to do. Is there a way to get around this? If Range("FBSMINT") 0 Then ' "trigger" cell Call FLBIN_SMI_H ' This hides the group 2, 3, 4, and 5 ranges Else If Range("FBSMINT") = 0 Then ' "trigger" cell, again Call FLBIN_SMI_UH 'This Unhides the group 2, 3, 4 and 5 Ranges End If End If If Range("FBSAINT") 0 Then Call FLBIN_SAI_H ' This hides group 1, 3, 4 and 5 ranges Else If Range("FBSAINT") = 0 Then Call FLBIN_SAI_UH ' This Unhides group 1, 3, 4 and 5 Ranges End If End If Therefore, If group 1 is selected, the Unhide instructions in group 2 undo, what group 1 is trying to do. However, I do need some whay of "unhiding" in case of a mistake or change of mind. End Result : As various selections are made within the various groupings on the contract templates, the template will shorten considerably, making it much easier to view and work with, by the salesmen. I hope my attempted explanations are not too convoluted. As you can see, I have no problem utilizing standard modules together with the worksheet module - I think it actually helps keep things clearer. I sure hope someone can help me with this. I'm very excited about what I see as the possibilities for this application. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet_Change(ByVal Target As Range) - Big Problems
Rick & Barb - Thanks for your responses.
Rick, you're code does not solve the problem. Barb, I tried playing around with your suggestion, but can't see even a partial solution with this. Beside not explaining myself clearly, I think the biggest problem is that I don't understand how the module works. I'm assuming that each time a "trigger" cell is changed, that all the instructions in the model are process (again). (it wouldn't particularily surprise me if I'm way off base here). This is what leads me to believe that the 2nd set of instructions "undoes" what was done in the first code. When the salesman selects an item in the group of 5, he doesn't need to see the other 4 groups anymore. That is what I'm then trying to Hide. However, he DOES need a way out again, in case someone changes their mind, or he made an entry error. That's what the Un-Hides are for. In the first code I sent, the "_H" stands for Hide and the "_UH" stands for UnHide. Perhaps the following would help make things a bit clearer, in terms of what I'm trying to do. A B 1 G-1 Descriptive Heading 2 G-1 Descriptions (multiple lines) 3 G-1 Descriptions (multiple lines) 4 G-2 Descriptive Heading 5 G-2 Descriptions (multiple lines) 6 G-2 Descriptions (multiple lines) 7 G-3 Descriptive Heading 8 G-3 Descriptions (multiple lines) 9 G-3 Descriptions (multiple lines) 10 G-4 Descriptive Heading 11 G-4 Descriptions (multiple lines) 12 G-4 Descriptions (multiple lines) 13 G-5 Descriptive Heading 14 G-5 Descriptions (multiple lines) 15 G-5 Descriptions (multiple lines) Line 1, 2, 3 are range named R1 Line 4, 5, 6 are range named R2 Etc. B1, B4, B7, B10, B13 are the trigger cells Selection is done by entering a "1" in appropriate cell ("B?") De-Selection is done by entering a "0" in appropriate cell OR by deleting the "1". If B1 SELECTED, then HIDE Ranges G-2, G-3, G-4, G-5 If B1 DE-SELECTED then UNHIDE Ranges G-2, G-3, G-4, G-5 If B3 SELECTED, Then HIDE Ranges G-1, G-3, G-4, G-5 If B3 DESELECTED, Then UNHIDE Ranges G-1, G-3, G-4, G-5 etc. Perhaps something like this needs to be set up using a standard module as well as the worksheet module. Is there any code that can be written in a standard module, that will "trigger" the same way as in the Worksheet module? "Barb Reinhardt" wrote: I suspect when you change something on your worksheet with code, it's triggering the worksheet change event again, but for a different group of cells. You may want to try Application.EnableEvents = FALSE 'at the beginning Application.EnableEvents = TRUE 'at the end -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "BEEJAY" wrote: I just "discovered" this by accident a few weeks ago. Have LOTS of application for it - but having problems setting it up. Situation: Have Five Groups. The First Line of Each Group will have the "trigger" in Cell E? Each Group has range name for complete group. If group 1 selected, the "undo" instructions of group 2 seem to void what the original selection was trying to do. Is there a way to get around this? If Range("FBSMINT") 0 Then ' "trigger" cell Call FLBIN_SMI_H ' This hides the group 2, 3, 4, and 5 ranges Else If Range("FBSMINT") = 0 Then ' "trigger" cell, again Call FLBIN_SMI_UH 'This Unhides the group 2, 3, 4 and 5 Ranges End If End If If Range("FBSAINT") 0 Then Call FLBIN_SAI_H ' This hides group 1, 3, 4 and 5 ranges Else If Range("FBSAINT") = 0 Then Call FLBIN_SAI_UH ' This Unhides group 1, 3, 4 and 5 Ranges End If End If Therefore, If group 1 is selected, the Unhide instructions in group 2 undo, what group 1 is trying to do. However, I do need some whay of "unhiding" in case of a mistake or change of mind. End Result : As various selections are made within the various groupings on the contract templates, the template will shorten considerably, making it much easier to view and work with, by the salesmen. I hope my attempted explanations are not too convoluted. As you can see, I have no problem utilizing standard modules together with the worksheet module - I think it actually helps keep things clearer. I sure hope someone can help me with this. I'm very excited about what I see as the possibilities for this application. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheet_Change(ByVal Target As Range) - Big Problems
Barb:
Further investigation and trial - Your are correct. Once I figured out that the Application.EnableEvents must be around EACH group, SOME things started to work as expected/needed. I still get stuck with the multiple "calls". See my "re-explanation" post. "Barb Reinhardt" wrote: I suspect when you change something on your worksheet with code, it's triggering the worksheet change event again, but for a different group of cells. You may want to try Application.EnableEvents = FALSE 'at the beginning Application.EnableEvents = TRUE 'at the end -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "BEEJAY" wrote: I just "discovered" this by accident a few weeks ago. Have LOTS of application for it - but having problems setting it up. Situation: Have Five Groups. The First Line of Each Group will have the "trigger" in Cell E? Each Group has range name for complete group. If group 1 selected, the "undo" instructions of group 2 seem to void what the original selection was trying to do. Is there a way to get around this? If Range("FBSMINT") 0 Then ' "trigger" cell Call FLBIN_SMI_H ' This hides the group 2, 3, 4, and 5 ranges Else If Range("FBSMINT") = 0 Then ' "trigger" cell, again Call FLBIN_SMI_UH 'This Unhides the group 2, 3, 4 and 5 Ranges End If End If If Range("FBSAINT") 0 Then Call FLBIN_SAI_H ' This hides group 1, 3, 4 and 5 ranges Else If Range("FBSAINT") = 0 Then Call FLBIN_SAI_UH ' This Unhides group 1, 3, 4 and 5 Ranges End If End If Therefore, If group 1 is selected, the Unhide instructions in group 2 undo, what group 1 is trying to do. However, I do need some whay of "unhiding" in case of a mistake or change of mind. End Result : As various selections are made within the various groupings on the contract templates, the template will shorten considerably, making it much easier to view and work with, by the salesmen. I hope my attempted explanations are not too convoluted. As you can see, I have no problem utilizing standard modules together with the worksheet module - I think it actually helps keep things clearer. I sure hope someone can help me with this. I'm very excited about what I see as the possibilities for this application. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
REPSOT?? Sub Worksheet_Change(ByVal Target As Range) | Excel Discussion (Misc queries) | |||
Using Worksheet_Change(ByVal Target As Range) | Excel Programming | |||
Private Sub Worksheet_Change(ByVal Target As Range) | Excel Programming | |||
Private Sub Worksheet_Change(ByVal Target As Range) | Excel Programming | |||
Many Sub Worksheet_Change(ByVal Target As Range) In One Worksheet | Excel Programming |