Sub is triggering Selection Change Sub

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
82
When I step through this sub, all of a sudden now it is triggering the Selection Change Sub I just made. This code was working fine. Now its not working and when I try to debug I see it jumping over to the Selection_Change Sub.
Anybody know why it keeps jumping over to that Sub?

Headscratcher

Code:
Sub AddAssetDocs()


With Sheets("Assets")
    On Error GoTo err_msg
    Dim Ncol As String
    Dim Zcol As String
    Dim CpRange As Range
    
   
     Ncol = .Range("N5:N500").SpecialCells(xlConstants).Address
    
     Debug.Print Ncol
     
     Zcol = .Range(Ncol).Offset(, 12).Address
               
     Debug.Print Zcol
     
     
 
    On Error GoTo err_msg
    CpRange = .Range(Zcol).SpecialCells(xlBlanks).Address
     Debug.Print CpRange
     If CpRange = 0 Then GoTo Skiptohere
     
     
        
    .Range(CpRange).Offset(, 1).Copy
End With


Sheets("Doc Checklist").visible=True 


With Worksheets("Doc Checklist")
    LstRow = .Range("D" & .Rows.Count).End(xlUp).Row + 1
    'fill next available cell with a new data
    .Range("D" & LstRow).PasteSpecial xlPasteValues
End With




'once again, using cprange we mark rows which have been copied to "Doc Checklist"
With Sheets("Assets")
    .Range(CpRange).Value = "x"
End With
 Application.CutCopyMode = False
 
MsgBox "These Documents have been added to the Doc Checklist"


GoTo Skiptohere




err_msg:
MsgBox "There are no new Docs to add to the list"


Skiptohere:


Worksheets("Assets").Select
Worksheets("Assets").Range("B1").Select


 Application.CutCopyMode = False
 
 With Sheets("Doc Checklist")
    .Range("C2:C500").Sort Key1:=.Range("C2"), order1:=xlAscending, Header:=xlNo
End With
 Worksheets("Doc Checklist").Range("D2:D100").Copy Worksheets("Doc Request").Range("I4:I100")
 Sheets("Doc Checklist").visible= False 


End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
When VBA writes to a worksheet, it will trigger that sheet's Change event unless you set EnableEvents to False beforehand.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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