+ Reply to Thread
Results 1 to 3 of 3

how to modify range in this code?

Hybrid View

kriminaal how to modify range in this... 08-22-2018, 12:00 PM
AlphaFrog Re: how to modify range in... 08-22-2018, 12:28 PM
kriminaal Re: how to modify range in... 08-22-2018, 01:13 PM
  1. #1
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    how to modify range in this code?

    I have this code (with help) working for deleting blank rows in the range A11:J45

    I need to add more ranges but I don't understand how it is entered in the code.
    I need to add A55:J89, A99:J133, A143:J147, A187:J204, A215:J232

    Sub Maybe()
        Dim lr As Long
        Dim i As Long
        Application.ScreenUpdating = False
        lr = Cells(Rows.Count, 1).End(xlUp).Row
        For i = lr To 12 Step -1
            If Range("A" & i).Offset(, 1).HasFormula = True And Range("A" & i).Offset(, 1).Value = 0 Or _
               Range("A" & i).Offset(, 1).HasFormula = True And Range("A" & i).Offset(, 1).Value = "" Or _
               Range("A" & i).Offset(, 1).Value = "" Then Range("A" & i).Resize(, 10).Delete Shift:=xlUp
        Next i
        Application.ScreenUpdating = True
    End Sub
    Many thanks

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: how to modify range in this code?

    Your existing code checks all the rows, the logic is not correct though...

    Sub Maybe()
        Dim lr As Long
        Dim i As Long
        Application.ScreenUpdating = False
        lr = Cells(Rows.Count, 1).End(xlUp).Row
        For i = lr To 12 Step -1
            If Range("B" & i).HasFormula = True And _
              (Range("B" & i).Value = 0 Or Range("B" & i).Value = "") Then _
               Range("A" & i).Resize(, 10).Delete Shift:=xlUp
        Next i
        Application.ScreenUpdating = True
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: how to modify range in this code?

    Oh okay, it seems to work.
    But your modifications do not.
    Okay I see it does all the rows, is there a way to change it to do just the Ranges I described?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Modify code to extend range
    By jrx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2016, 01:36 PM
  2. Modify code to select range of cells
    By microhunt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-16-2014, 03:46 PM
  3. [SOLVED] Modify VBA Code Search Hilight from 1 range to multiples range?
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2014, 08:04 PM
  4. How to modify Worksheet_Change Macro VBA code from Range to Cell
    By AGCSC1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 04:23 PM
  5. Recorded Code/Modify/Convert Range to Dynamic
    By nuttycongo123 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-08-2011, 08:35 PM
  6. Modify code to change Sum Range
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-28-2010, 03:32 PM
  7. Modify code to drag cell contents across a row range
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-20-2010, 04:34 PM

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