Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
And to add, the selectionchange event must be in the sheet module. You can
have the event call a separate subroutine located in the general module that contains teh voluminous code that you show. Private Sub Worksheet_SelectionChange(ByVal Target As Range) myprocedure End Sub in a general module Sub MyProcedure() x_t_0 = 0 Cells(13, "B").Value = x_t_0 'nivo's boven de gaten N_0 = Cells(7, "K").Value N_1 = Cells(6, "K").Value N_2 = Cells(5, "K").Value N_3 = Cells(4, "K").Value N_4 = Cells(3, "K").Value '=MAX($K$7-B17;0 H_0_0 = Application.WorksheetFunction.Max((N_0 - x_t_0), 0) Cells(13, "C").Value = H_0_0 H_1_0 = Application.WorksheetFunction.Max((N_1 - x_t_0), 0) Cells(13, "D").Value = H_1_0 H_2_0 = Application.WorksheetFunction.Max((N_2 - x_t_0), 0) Cells(13, "E").Value = H_2_0 H_3_0 = Application.WorksheetFunction.Max((N_3 - x_t_0), 0) Cells(13, "F").Value = H_3_0 H_4_0 = Application.WorksheetFunction.Max((N_4 - x_t_0), 0) Cells(13, "G").Value = H_4_0 etc etc etc... End Sub The advice to qualify this with the worksheet is sound, but since the routine is called from the selectionchange event, the appropriate sheet will be the activesheet and it isn't essential. -- Regards, Tom Ogilvy "Robert" wrote: Hello, I have a great amount of code behind "Sheet1". I would like to create parts. I tried putting it into modules, but then this code doesnt work. This is the first part of the code.. Private Sub Worksheet_SelectionChange(ByVal Target As Range) x_t_0 = 0 Cells(13, "B").Value = x_t_0 'nivo's boven de gaten N_0 = Cells(7, "K").Value N_1 = Cells(6, "K").Value N_2 = Cells(5, "K").Value N_3 = Cells(4, "K").Value N_4 = Cells(3, "K").Value '=MAX($K$7-B17;0 H_0_0 = Application.WorksheetFunction.Max((N_0 - x_t_0), 0) Cells(13, "C").Value = H_0_0 H_1_0 = Application.WorksheetFunction.Max((N_1 - x_t_0), 0) Cells(13, "D").Value = H_1_0 H_2_0 = Application.WorksheetFunction.Max((N_2 - x_t_0), 0) Cells(13, "E").Value = H_2_0 H_3_0 = Application.WorksheetFunction.Max((N_3 - x_t_0), 0) Cells(13, "F").Value = H_3_0 H_4_0 = Application.WorksheetFunction.Max((N_4 - x_t_0), 0) Cells(13, "G").Value = H_4_0 etc etc etc... Is it possible to split this into more modules are what so ever and that it just keeps on working like it does now? I want to do this because I am losing track and get tired of scrolling. Robert. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do i organise a schedule | Excel Discussion (Misc queries) | |||
How to organise expenses divided between two payers | New Users to Excel | |||
Re-organise columns so they appear in alphabetical order? | Setting up and Configuration of Excel | |||
how can I use use exel to organise my bank details | New Users to Excel | |||
how to group a row so i can organise data by diff fields | Excel Discussion (Misc queries) |