Results 1 to 5 of 5

Code to Loop and Delete Relevant String

Threaded View

  1. #1
    Registered User
    Join Date
    01-27-2015
    Location
    Colorado
    MS-Off Ver
    2013
    Posts
    2

    Code to Loop and Delete Relevant String

    Hi there,

    I'm trying to edit a macro I originally recorded that ended up being about 3000 lines, about 2000 of which are "ActiveWindow.ScrollColumn = x". These "ActiveWindow.ScrollColumn = x" are the lines I'm trying to remove to ultimately clean up the original script. So, I copied and pasted the lines of code into an Excel spreadsheet in an effort to write some more code to loop through these cells and delete the scrolling lines.

    My sub looks like this:

    ''Deleting Scrolls Script
    Sub deleteScrolls()
    Dim i As Integer
    For i = 1 To Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
    If Cells(i, 1).Value Like "ActiveWindow.ScrollColumn" Then
    Rows(ActiveCell.Row).Select
    Selection.Delete Shift:=xlUp
    End If
    Next i
    End Sub

    I also tried a slightly different version of the code:

    'test 2
    Sub deleteScrolls()
    Dim i As Integer
    For i = 1 To Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
    If ActiveCell.Value Like "*ActiveWindow.ScrollColumn*" Then
    Rows(ActiveCell.Row).Select
    Selection.Delete Shift:=xlUp
    End If
    Next i
    End Sub

    So I'm trying to loop through and delete any lines that have the value of the ActiveWindow.ScrollColumn using the Like command. I'm assuming this part is where the code is falling short.

    I have attached a screenshot of the Excel doc with an example of the lines I'm trying to delete.

    Any help would be greatly appreciated.
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Do while loop to capture relevant data from a master sheet?
    By monkeypants in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-12-2014, 11:42 AM
  2. Excel Web scraping loop and filling the relevant cells
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 12-20-2012, 07:33 AM
  3. [SOLVED] VB Code To Delete Rows between 2 flags on loop
    By shauncol3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2012, 07:46 PM
  4. excel vba macro loop using save and delete code
    By she_armario in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-05-2012, 03:04 AM
  5. vba code to delete rows with string of text found
    By yankeekid86 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-14-2011, 07:08 PM
  6. vba code to delete rows with string of text found
    By yankeekid86 in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 09-13-2011, 11:50 PM
  7. Adding a loop to conditional delete code
    By maw via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 21
    Last Post: 08-15-2006, 11:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1