+ Reply to Thread
Results 1 to 7 of 7

Change array to include new cells

Hybrid View

nsorden Change array to include new... 08-14-2009, 12:44 PM
JBeaucaire Re: Change array to include... 08-14-2009, 12:53 PM
MickG Re: Change array to include... 08-14-2009, 01:03 PM
nsorden Re: Change array to include... 08-14-2009, 02:06 PM
nsorden Re: Change array to include... 08-14-2009, 02:08 PM
nsorden Re: Change array to include... 08-14-2009, 02:28 PM
MickG Re: Change array to include... 08-15-2009, 06:10 AM
  1. #1
    Registered User
    Join Date
    06-02-2009
    Location
    Arlington, VA
    MS-Off Ver
    Excel 2007
    Posts
    80

    Change array to include new cells

    I am having a ton of trouble with this. I am trying to add a single text row in between existing data. I have tried multiple loops to try to place an array into Column G, but I cannot figure it out. Is there some coding that will produce the sort of result below in column G?

    Col E	Col F	Col G
    		
    a	1	a
    a	1	a
    a	1	a
    b	0	SUMMARY
    b	0	b
    b	0	b
    b	0	b
    b	0	b
    c	1	b
    c	1	SUMMARY
    c	1	c
    c	1	c
    d	0	c
    e	1	c
    e	1	SUMMARY
    f	0	d
    f	0	SUMMARY
    		e
    		e
    		SUMMARY
    		f
    		f
    		SUMMARY
    Last edited by nsorden; 08-31-2009 at 02:26 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change array to include new cells

    You actually need this done IN column G? Or is column G your representation of what you want to happen in column E?

    We want the row inserted when the value in column E changes?

    Is the word "SUMMARY" supposed to be entered, or a SUM() formula for that section? Or "Summary" in column E and a SUM() formula in column F?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Change array to include new cells

    Hi, Try:-
    Sub MG14Aug52
    Dim Last As Integer, Del As Long
    Dim Rng As Range, Dn As Range
    Set Rng = Range(Range("c1"), Range("c" & Rows.Count).End(xlUp))
         For Del = Rng.Count To 2 Step -1
            With Range("c" & Del)
                If Not .Value = .Offset(-1).Value Then
                    .Insert
                    .Offset(-1).Value = "Summary"
                End If
            End With
    Next Del
    End Sub
    Regards Mick

  4. #4
    Registered User
    Join Date
    06-02-2009
    Location
    Arlington, VA
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Change array to include new cells

    You actually need this done IN column G? Or is column G your representation of what you want to happen in column E?

    We want the row inserted when the value in column E changes?

    Is the word "SUMMARY" supposed to be entered, or a SUM() formula for that section? Or "Summary" in column E and a SUM() formula in column F?
    1)Column G in the post is what I would like to happen IN column G
    2)"Summary" should be entered when value in Column E changes
    3)"Summary" actually entered, not a summation.

  5. #5
    Registered User
    Join Date
    06-02-2009
    Location
    Arlington, VA
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Change array to include new cells

    Why column C?


    Sub MG14Aug52
    Dim Last As Integer, Del As Long
    Dim Rng As Range, Dn As Range
    Set Rng = Range(Range("c1"), Range("c" & Rows.Count).End(xlUp))
    For Del = Rng.Count To 2 Step -1
    With Range("c" & Del)
    If Not .Value = .Offset(-1).Value Then
    .Insert
    .Offset(-1).Value = "Summary"
    End If
    End With
    Next Del
    End Sub

  6. #6
    Registered User
    Join Date
    06-02-2009
    Location
    Arlington, VA
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Change array to include new cells

    MickG's solution seems to work, but I might have simplified my example a little too much. Each of the letters in the example corresponds to a number, so instead of the code placing a summary in between repeating letters, it needs to be placed in between non-repeating numbers that correspond to the letters. The letters determine the change but should not be placed in between the summaries.
    Something similar to this:
    Summary
    10974457
    73031672
    25302339
    Summary
    28546618
    19546623
    29346619
    29546621
    29547624
    Summary

  7. #7
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Change array to include new cells

    Hi, Try this:-
    Sub MG15Aug51
    Dim Last As Integer, Del As Long
    Dim Rng As Range, Dn As Range
    Set Rng = Range(Range("e1"), Range("e" & Rows.Count).End(xlUp))
    'Remove line below if Word "Summary Not wanted at Bottom of Col "G"
             Range("G" & Rng.Rows.Count + 1) = "Summary"
    
         For Del = Rng.Count To 2 Step -1
            With Range("e" & Del)
                If Not .Value = .Offset(-1).Value Then
                    .Offset(, 2).Insert
                    .Offset(, 2).Value = "Summary"
                End If
            End With
    Next Del
    End Sub
    Regards Mick

+ 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