Consulting

Results 1 to 5 of 5

Thread: Insert End

  1. #1
    VBAX Contributor
    Joined
    Apr 2010
    Posts
    182
    Location

    Insert End

    Hi,

    I'm trying to figure out a code that would insert the text "End" below the last data row of column "D" when the worksheet is activated.

    Any help on this would be kindly appreciated.

    Thanks in advance.
    Best Regards,
    adamsm

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Private Sub Worksheet_Activate()
    Cells(Rows.Count, 4).End(xlUp)(2) = "End"
    End Sub[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Contributor
    Joined
    Apr 2010
    Posts
    182
    Location
    Thanks for the code mdmackilop. I've changed the code slight bit.

    My intention is to add the formula to the column "T" so that each time the worksheet gets activated the formula gets copied to the row below the last data row and sum ups the column from row 17.

    But my modification isn't working. How may I do what is being told above?

    [VBA]Private Sub Worksheet_Activate()
    Cells(Rows.Count, 4).End(xlUp)(2) = "End"
    Cells(Rows.Count, 20).End(xlUp)(2) = "=SUBTOTAL(109,T1:T10000)"
    End Sub[/VBA]

    Any help on this would be kindly appreciated.
    Best Regards,
    adamsm

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I'm not clear on your sub-total function. What is the 109 value? I'd have thought you want something like
    [VBA] Cells(Rows.Count, 20).End(xlUp)(2).FormulaR1C1 = "=SUBTOTAL(9,R1C:R[-1]C)"
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Contributor
    Joined
    Apr 2010
    Posts
    182
    Location
    Thanks for the help. It Worked Fine. And I do really appreciate your help.
    Best Regards,
    adamsm

Posting Permissions

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