Results 1 to 17 of 17

Automatically change the range of the Macro Formula when i insert column or row ??

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-20-2015
    Location
    philippines
    MS-Off Ver
    2013
    Posts
    260

    Automatically change the range of the Macro Formula when i insert column or row ??

    Automatically change the range of the Macro Formula when i insert column or row

    Hello excel forum.. is it possible to automatically change the range of the formula in my macro code ?
    For example: i create a code in my sheet 1. get the sum in H1:H10 the result is in H11.. and when i try to insert a row or column Between my the range i set
    it will automatically change the range ?

    like when you create a formula not using the macro.. when you add other column or row in the range of the formula. the formula will adjust..
    is it possible ? anybody can help me..

    sorry for my grammar if you don' understand.. i wish anybody here can help me.. Thanks GOD Bless..



    Here's the code
    'Set a Formula in sheet.
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Cells.CountLarge > 1 Then Exit Sub
        
        If Not Intersect(Target, Range("H1:H500")) Is Nothing Then
            If Target.Address <> "$H$11" Then
                Application.EnableEvents = False
                    Range("H11").Formula = "=SUM(H1:H10)"
                Application.EnableEvents = True
            End If
        End If
        
        If Not Intersect(Target, Range("F1:F500")) Is Nothing Then
            If Target.Address <> "$F$11" Then
                Application.EnableEvents = False
                    Range("F11").Formula = "=SUM(F1:F10)"
                Application.EnableEvents = True
            End If
        End If
    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. [SOLVED] Insert Sumif formula but range may change
    By batchy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2014, 12:36 AM
  2. [SOLVED] Need a code or formula that will automatically change the named range in my formulas
    By mo4391 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2013, 11:24 AM
  3. Macro to insert row(s) and copy the formula and value of cell(s) automatically
    By jwidjaja in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2013, 05:35 PM
  4. Insert row after date change
    By nana15nuna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2012, 11:43 PM
  5. Need to create a macro to insert row after a value change in a column
    By vjboaz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2008, 02:04 PM
  6. Macro to insert this formula automatically on start up
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-07-2005, 06:25 PM
  7. macro to Insert rows at every change in a column
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2005, 09:05 AM

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