Would like Target.Address to only run from one module

ArnMan

Board Regular
Joined
Aug 30, 2017
Messages
69
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,
I have several modules housing different code. Each Code runs in the same Range Area. I have one module that gives a place to put a value in J5. And from there is uses Worksheet_Change to run a separate Module. I've added the "If Target.address section" after a Select Case setup. This works the way it is. But if I put another module that gives a value, or a user inputs a Value into J5 the Worksheet_Change fires off the Target address and runs the original Module that it was designed for. Giving the result I am looking for something else.
I am sure I've left something out, if I have I apologize. I figure if I can reword the Worksheet_Change Target.Address to only look for $J$5 coming out of 1 module I'd be happy unless there is another place I can stick that.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B2")) Is Nothing Then
    Select Case Range("B2")
        Case "Normal Test Point": ExampleNormalTestRow
        Case "Blank Line": ExampleBlankLine
        Case "Section Title": ExampleSectionTitleRow
        Case "Accuracy": ExampleAccuracyRow
    End Select
End If

If Target.Address = "$J$5" Then
Call LCB2
Call HCB2
End If

End Sub
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
that module should only be on the sheet you want to monitor, or am I missing something
 
Upvote 0
Although it might be a little bothersome, you could be prompted asking whether you want to run the macros or not.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B2")) Is Nothing Then
        Select Case Range("B2")
            Case "Normal Test Point": ExampleNormalTestRow
            Case "Blank Line": ExampleBlankLine
            Case "Section Title": ExampleSectionTitleRow
            Case "Accuracy": ExampleAccuracyRow
        End Select
    End If
    If Target.Address = "$J$5" Then
        If MsgBox("Do you want to call LCB2 and HCB2?", vbYesNo) = vbYes Then
            Call LCB2
            Call HCB2
        End If
    End If
End Sub
 
Upvote 0
that module should only be on the sheet you want to monitor, or am I missing something
Well I had to made a seperate module for those two calls because there werent updating automatically. Lets say I entered a value in J5 and wanted the answer to be in I9. when it was entered, because I needed NumberFormat ran it wouldnt update unless I reran the Sub, leaving the value in place then it would update I9. And if I needed to change the value in J5, it wouldnt autoupdate, so i needed it to be WorkSheet_Change.
I dont know if I explained that correctly or not. If I havent I apologize.

I was having that not updating problem in my other post
https://www.mrexcel.com/forum/excel-questions/1021806-setting-numberformat-if-statement-2.html

Which with the help of Rick and dmt32, I was able to fix that.
 
Upvote 0
Well there are going to be alot of other people using this and I was hoping to streamline my Worksheet as much as possible. I dont want people getting confused.
If all else fails, I will just program everything from not using the J5 cell except for the original module.

Although it might be a little bothersome, you could be prompted asking whether you want to run the macros or not.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B2")) Is Nothing Then
        Select Case Range("B2")
            Case "Normal Test Point": ExampleNormalTestRow
            Case "Blank Line": ExampleBlankLine
            Case "Section Title": ExampleSectionTitleRow
            Case "Accuracy": ExampleAccuracyRow
        End Select
    End If
    If Target.Address = "$J$5" Then
        If MsgBox("Do you want to call LCB2 and HCB2?", vbYesNo) = vbYes Then
            Call LCB2
            Call HCB2
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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