Combining 2 Worksheet_Change events

orion2323

New Member
Joined
Dec 20, 2017
Messages
26
Hello again!

I could use a little help with the following :)

How can I go about combining these 2 events: (If possible)

#1 takes a formula result from one cell, and pastes the value to a different cell
#2 will automatically print when a cell value matches the trigger

#1
Code:
Option Explicit
 
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B5")) Is Nothing Then
    If InStr(1, Target, "COLOR", vbTextCompare) Then
        Target.Offset(0, 1) = "COLOR"
    End If
End If
End Sub
#2
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim targCell As Range
    Set targCell = Worksheets(1).Range("B2")
 
    If Not Application.Intersect(Target, targCell) Is Nothing Then
        If targCell.Value = COLOR Then
            Worksheets(1).PrintOut
        End If
    End If
End Sub
Thank you All for your time!
 
Last edited by a moderator:
That did it!!!!!!!!!!!!!!!!!!!!!!!
:)

Thank you very much "Joe". You have been extremely helpful

Have a great day, year ahead!
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You are welcome!

Yes, I figured that you really just wanted to check the value you just changed, and not the whole range.
 
Upvote 0
I'm back with more questions :)

So I'd like to know if it's possible to automate TWO steps (key strokes) while keeping the printing macro already in use ?

I'm scanning a number into cell B2, scanner automatically switches to cell C2, I then complete the cell with a particular value (2, which triggers the print macro) and tab to cell D2 and enter another value (let's say 1) and this completes the process. Excel jumps to the next row, staring in B3

Is there a way to automate this process ?
(I could use a formula such as this for cells C2 (=IF(B2<>"",2,"")) and D2 (=IF(C2<>"",1,""))
But I need a tiny delay from one action to the other, so after scanning to cell B2, the formula enters a value to C2 (excel prints) then the formula enters a value in D2, excel returns to the row below (B3)

Thanks again!
 
Upvote 0
This really is a new question, so I would recommend posting it to a new thread.
I would recommend posting the code that you currently have that you want to build off of, and then include your description of what you want to add to it.
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,341
Members
452,638
Latest member
Oluwabukunmi

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