Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro Help (2003)

    I created the following macro:
    Sub Arlene()
    '
    ' Arlene Macro
    ' Macro recorded 02/20/2007

    '
    Columns("A:L").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    With Selection.Interior
    .ColorIndex = 11
    .Pattern = xlSolid
    .PatternColorIndex = 1
    End With
    End Sub

    It basically highlights columns A-L and go to blanks and then colors the blanks dark blue. The macro is fine but I would like the macro to stop short of the last line with data in it. I do not want to color the blanks in the last line that contains data. How would I code this in the above macro? Thanks for any help you can provide.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro Help (2003)

    Try this version:

    Sub Arlene()
    Dim rng As Range
    Set rng = Intersect(Columns("A:L"), ActiveSheet.UsedRange)
    Set rng = rng.Resize(rng.Rows.Count - 1)
    With rng.SpecialCells(xlCellTypeBlanks).Interior
    .ColorIndex = 11
    .Pattern = xlSolid
    .PatternColorIndex = 1
    End With
    End Sub

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Help (2003)

    Thanks Hans. It works on the first tabbed sheet of the workbook but it doesn't on subsequent worksheets in the workbook. On the first worksheet it highlights all blanks in columns A-L except for the total line. The next two worksheets it highlights the blanks in the total line.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro Help (2003)

    Is there a column in the range A:L that will always have an entry in the last used row? If so, which column?

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Help (2003)

    If I edit, clear, all - the cells below the last line that has data in it, the macro works. Is there a way to add that to the macro?

    It looks like Column A will have an entry in the last used row.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro Help (2003)

    Try this version. It doesn't require cells below the last used row to be cleared.

    Sub Arlene()
    Dim n As Long
    n = Range("A65536").End(xlUp).Row - 1
    With Range("A1:L" & n).SpecialCells(xlCellTypeBlanks).Interior
    .ColorIndex = 11
    .Pattern = xlSolid
    .PatternColorIndex = 1
    End With
    End Sub

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Help (2003)

    Thanks Hans - that worked.

Posting Permissions

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