Note that there are some explanatory texts on larger screens.

plurals
  1. POCombine two subs with changing ranges
    primarykey
    data
    text
    <p>I want to combine these two lines of code but cannot figure out how to get it to work. They both work separately, but I want the first line of code to be the first operation and then the second sub to be the second operation. These should execute whenever there is a change to the worksheet. The first routine should only cause a msg box when the corresponding cell in the "S" range updates in the same row as the cell that was updated in column A or B.</p> <p>The second operation should look for any change in range "T7:T26" and prompt a msg box.</p> <p>Code is below:</p> <pre><code> Private Sub Worksheet_Change(ByVal Target As Range) Dim myRng As Range Dim lRow As Long If Target.CountLarge &gt; 1 Then Exit Sub On Error GoTo Whoa Set myRng = Range("A7:B26") Application.EnableEvents = False If Not Intersect(Target, myRng) Is Nothing Then lRow = Target.Row If Range("S" &amp; lRow).Value &gt;= 16 Then sVar = _ MsgBox("Will Enough Pre-Wave Resources be Available?", 4, "Attention!") If sVar = 7 Then Application.Undo End If Letscontinue: Application.EnableEvents = True Exit Sub Whoa: MsgBox Err.Description Resume Letscontinue End Sub </code></pre> <p>and </p> <pre><code> Private Sub Worksheet_Change(ByVal Target As Range) Dim myRng As Range Set myRng = ThisWorkbook.Sheets("SMT 5").Range("T7:T26") For Each mycell In myRng If mycell.Value = "ISSUE" Then sVar = MsgBox("Possible Pre-Wave Manpower Issue on 2nd or 3rd Shift. Will Enough Resources be Available?", 4, "Attention!") If sVar = 7 Then Application.Undo End If Exit For Next End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload