Results 1 to 2 of 2

VBA Underline macro starts line too far to the right

Threaded View

  1. #1
    Registered User
    Join Date
    06-10-2004
    Posts
    22

    VBA Underline macro starts line too far to the right

    All,

    I have a macro, I'm utilizing to "try" and underline part of a row were the values in a column change. In the worksheet, where the field "TICS #" changes I would like to underline columns "D" to "R". I have it correct where the line is created when column "I" changes; however, the underline starts there too. Like I had mentioned, I would like the underline to go from column "D" to column "R". Currently, it's going from column "I" to column "Z". As always, thanks in advance. Here is the code and I've attached a sample file.

    Sub Underline()
    Dim rng As Range, lRw As Long, lCol As Long
    
    lRw = Range("A" & Rows.Count).End(xlUp).Row
    lCol = Columns("R:R").Column
    Set rng = Range(Cells(1, 1), Cells(lRw, lCol))
    With rng.Resize(lRw + 1)
        .Borders(xlInsideHorizontal).LineStyle = xlNone
    End With
    For Each c In rng.Columns(9).Cells
        If c.Value <> c.Offset(1, 0).Value Then
            With c.Resize(1, lCol).Borders(xlEdgeBottom)
                .LineStyle = xlContinuous
                .ColorIndex = 9
                .Weight = xlThick
            End With
        End If
    Next c
        
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Create a macro to underline
    By steadyeddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2013, 12:43 PM
  2. Underline same length as the total on the next line
    By mikeburg in forum Excel General
    Replies: 3
    Last Post: 11-18-2007, 04:44 AM
  3. [SOLVED] Can you type a line over text (opposite of underline)?
    By Matt in forum Excel General
    Replies: 1
    Last Post: 05-26-2006, 12:00 PM
  4. [SOLVED] Borders nor underline commands remove an unusual underline. ??
    By VideoFreak in forum Excel General
    Replies: 4
    Last Post: 02-11-2006, 04:20 PM
  5. Strikethough and Underline Macro
    By Rainman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-07-2005, 06:05 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