Reducing workbook memory space

singcbl

Well-known Member
Joined
Feb 8, 2006
Messages
518
I have this workbook with about ever increasing worksheets. At the present moment it stand at 50 worksheets and counting. On every worksheet is a worksheet selection change event routine that I am trying to trim the size by having some of the codes transfer or alter into a module sheet. That is to say each worksheet will use a call routine to execute the change event. Below is the original codes in the worksheet.
Once again appreciate any help I can get.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim frmUF As UserForm1
Dim frmUF2 As UserForm2
Dim frmUF3 As UserForm3
Dim frmUF4 As UserForm4
Dim lRowEnd As Long
Dim sDataRange As String

If Not Intersect(Target, Range("$K$4:$N$4")) Is Nothing Then
    Set frmUF = New UserForm1
    With frmUF
        .SelectionDataList = "Menu!Risk_Likelihood2"
        .Show
        If .SelectedValue <> "" Then Target.Value = .SelectedValue
    End With

ElseIf Not Intersect(Target, Range("$K$5:$N$5")) Is Nothing Then
    Set frmUF2 = New UserForm2
    With frmUF2
        .SelectionDataList = "Menu!Risk_Impact2"
        .Show
        If .SelectedValue <> "" Then Target.Value = .SelectedValue
    End With

ElseIf Not Intersect(Target, Range("$G$6:$I$6")) Is Nothing Then
    Set frmUF3 = New UserForm3
    With frmUF3
        .SelectionDataList = "Menu!Action_Status"
        .Show
        If .SelectedValue <> "" Then Target.Value = .SelectedValue
    End With

ElseIf Not Intersect(Target, Range("$I$12:$N$12")) Is Nothing Then
    Set frmUF4 = New UserForm4
    With frmUF4
        .SelectionDataList = "Menu!Risk_Response"
        .Show
        If .SelectedValue <> "" Then Target.Value = .SelectedValue
    End With
End If
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
So can you not just take what you have, stick it in a module and call the Sub from each worksheet under the change event?
 
Upvote 0
Lewiy,

I was trying to do that but didn't know what must put in module and respective worksheets.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,181
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top