Results 1 to 3 of 3

Thread: How to insert line in Excel using VBA

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Chicago
    Posts
    97

    Arrow

    Hi,
    I want to place a horizontal line in Excel using VBA.Actually iam working with Excel object in VB.Iam able to insert a vertical line with some code but with other options iam not able to insert horizontal line.Can anyone please help me out with this.
    Here is the code for the vertical line

    Worksheets("Sheet1").Range("A1:G1").Borders(xlDiagonalUp).Color = RGB(255, 195, 0)

    Also i want to insert page numbers in the footer like

    Page i of n.

    Using VBA can anyone tell me as what code to write to display the page numbers.

    I will be very much thankful to you if you can give solution to these.

    Thanks

    Regards
    Anil
    Anil

  2. #2
    Addicted Member
    Join Date
    Oct 2000
    Location
    Vienna/Austria
    Posts
    132
    Hi anilgoje !!!

    Hope this helps.
    The example below tested in EXCEL 97 !

    One Hint, if you use the macro recorder, much of your work
    is already done.

    -cu TheOnly


    'select the worksheet
    With Worksheets("sheet1")

    'select the range we want to use
    With .Range("a1:g1,a1:a10")

    'Note: if you use thin lines for the borders
    ' somtimes the doesn't appear in the sheet
    ' change to the preview window - then you can
    ' see it !!!

    'top border line
    With .Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .Weight = xlThick
    .Color = RGB(255, 195, 0)
    End With

    'left border line
    With .Borders(xlEdgeLeft)
    .LineStyle = xlContinuous
    .Weight = xlThick
    .Color = RGB(255, 195, 0)

    End With
    End With

    'setup footer
    'see excel help
    .PageSetup.LeftFooter = "Sheet &P of " & " &N"

    End With

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Chicago
    Posts
    97

    Thanks Alot!!!! The Only

    Thanks Alot!!! TheOnly..
    You gave me exactly what i want.Now it is working nicely.Thank you very much for your support.I appreciate you very much.
    Once again....Thanks alot..The Only

    Regards

    Anil
    Anil

Posting Permissions

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



Click Here to Expand Forum to Full Width