+ Reply to Thread
Results 1 to 8 of 8

VBA code for presentable excel report to receipients

Hybrid View

  1. #1
    Registered User
    Join Date
    12-09-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    VBA code for presentable excel report to receipients

    Anyone here know how to change my code to draw a horizontal thick border after each number sequence change in column B.

    I have searched all the canned excel views and none work, seems like a lot of folks would need to make the excel report presentable by automation, I cannot figure out the sequence change part?



    Code:
    Dim r As Range
    Set r = Range(Range("b8"), Range("b" & Rows.Count).End(xlUp))
    r.Select
    Dim cell As Range
    For Each cell In r
    '************************************************
    'Draw Horizontal Lines or clear horizontal lines
    '************************************************
    If cell.Offset(1, 0).Value <> "" Then Call DrawThickHoriziontalLineBelowRange(Range(Cells(cell.Row, 2), Cells(cell.Row, 12)))
    Next cell
    End Sub
    Sub DrawThickHoriziontalLineBelowRange(r As Range)
    With r.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .Weight = xlThick
    .ColorIndex = xlAutomatic
    End With
    End Sub
    Sub ClearHoriziontalLineBelowRange(r As Range)
    r.Borders(xlEdgeBottom).LineStyle = xlNone
    End Sub

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA code for presentable excel report to receipients

    hi Jeromeisma, can you post sample workbook showing original data and result you need to obtain?

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA code for presentable excel report to receipients

    please check attachment sample, press "Underline", hope it helps
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-09-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code for presentable excel report to receipients

    I attached an example of what I am looking for.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA code for presentable excel report to receipients

    please check attachment
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-09-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code for presentable excel report to receipients

    That is what I am looking for, works perfectly.

    What part of the code would I copy if I just wanted to use the macro and not the button, I have never used buttons before, I would just copy the macro and rename it?

    Thanks so much for the help, this is awesome......

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA code for presentable excel report to receipients

    the code itself:

    Sub test()
    Dim myrng As Range, cl
    
    Application.ScreenUpdating = 0
    
    With ActiveSheet
        
        .Range("a1").CurrentRegion.Borders.LineStyle = xlContinuous
        
        Set myrng = .Range("b2", .Cells(Rows.Count, "b").End(xlUp).Offset(1))
        
            For Each cl In myrng
            
                With cl
                
                    If .Value <> cl.Offset(1).Value Then
                    
                        With .Resize(, 11).Borders(xlEdgeBottom)
                            .LineStyle = xlContinuous
                            .Weight = xlThick
                        End With
                        
                    End If
                
                End With
                
            Next
        
    End With
    
    Application.ScreenUpdating = 1
    
    End Sub

  8. #8
    Registered User
    Join Date
    12-09-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code for presentable excel report to receipients

    Perfection, Thanks so much, I will be back when I have other questions, this site is AWESOME.........

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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