Consulting

Results 1 to 3 of 3

Thread: VBA/VBE Weird behavior when deleting a code line in a sub using a different sub

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA/VBE Weird behavior when deleting a code line in a sub using a different sub

    Hi, here is my situation. I am using a .deleteLines to delete certain lines of code in a Sub. Whenever the .deleteLines happens, a popup appears (added as a screenshot: untitled.bmp) mentioning Break is pretty much disabled going forward. From that moment, it is impossible for me to break at a specific line after the .deleteLines code line. My first question is: Is this avoidable? and 2nd question: If not, is there a way to reactivate Breaks?

    Workbook1 opens Workbook 2 using Application.Run MacroName

    MacroName (in Workbook2) uses the following code to delete certain lines:

    ModuleName = "MyModule"
    
    
                Set VBProj = ActiveWorkbook.VBProject
                Set VBComp = VBProj.VBComponents(ModuleName)
                Set CodeMod = VBComp.CodeModule
                Dim SLS As Long ' start line
                Dim SCS As Long ' start column
                Dim ECS As Long ' end column
                Dim SLE As Long ' start line
                Dim SCE As Long ' start column
                Dim ECE As Long ' end column
    
    
                SLS = 1
                SCS = 1
                ECS = 255
    
    
                SLE = 1
                SCE = 1
                ECE = 255
    
    
                With CodeMod
                    FoundStart = .Find(Target:=StartCode & AddedVariable, StartLine:=SLS, StartColumn:=SCS, EndLine:=.CountOfLines, EndColumn:=ECS, wholeword:=True, MatchCase:=False, patternsearch:=False)
                    FoundEnd = .Find(Target:=EndCode & AddedVariable, StartLine:=SLE, StartColumn:=SCE, EndLine:=.CountOfLines, EndColumn:=ECE, wholeword:=True, MatchCase:=False, patternsearch:=False)
    
    
                    LineStart = SLS + 1
                    LineEnd = SLE - 1
                    NumberofLinestoDelete = SLE - LineStart
    
    
                    .DeleteLines LineStart, NumberofLinestoDelete

    End With

    Any help would be greatly appreciated!

    Thanks
    Last edited by SamT; 02-17-2016 at 07:59 PM. Reason: added CODE TAgs with editor' # Icon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •