Results 1 to 10 of 11

Thread: Copying Data From One Range to Another By Averaging the Intersection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    14
    @Rick
    Although the OP did't ask for any flexibility, I think it's the most flexible one:

    Code:
    Sub M_snb()
      Range("C9:F10").Name = "snb1"
      Range("I9:L10").Name = "snb2"
      
      [snb1] = [if(snb1*snb2>0,int((snb1+snb2)/2),if(snb1&snb2="","",snb1+snb2))]
    End Sub
    If you 'abhorr' square brackets, use

    Code:
    Range("snb1") = Evaluate("if(snb1*snb2>0,int((snb1+snb2)/2),if(snb1&snb2="""","""",snb1+snb2))")
    @Steve

    Avoid activate in VBA.
    The use of 'Let' is redundant in VBA.
    I tried to incorporate my suggestion into your snippet:
    Code:
    Sub Freeze()
        Dim Tt As Long
        Dim Rb As Integer
        Tt = Application.Range("WHERE15").Value
        Rb = Application.Range("reachBACK").Offset(0, -1).Value
        
        If Rb > Tt - 3 Then Rb = Tt - 4
        If Rb <> 0 Then
            Application.ScreenUpdating = False
            Application.Calculation = xlCalculationManual
            
            With Sheets("INVESTOR INTERFACE")
                .Cells(Tt - Rb, 128).Resize(Rb, 3).Name = "snb1"
                .Range("snb1").Offset(, 13).Name = "snb2"
                [snb1] = [if(snb1*snb2>0,int((snb1+snb2)/2),if(snb1&snb2="","",snb1+snb2))]
                If Tt > 12 Then .Range("snb1").Offset(-11, 0).Resize(24, 3).ClearContents
            End With
            Application.Calculation = xlCalculationAutomatic
        End If
    End Sub
    Last edited by snb; 11-27-2012 at 04:32 PM.

Similar Threads

  1. Intersection of Overlapping Ranges:Space Operator
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-17-2013, 12:32 AM
  2. Copying formulas while keeping formating
    By Bradh in forum Excel Help
    Replies: 1
    Last Post: 12-02-2012, 11:32 AM
  3. Combining data of Two Array or Range
    By princ_wns in forum Excel Help
    Replies: 5
    Last Post: 10-01-2012, 06:52 PM
  4. copying data from multiple workbooks into another
    By rahulcoolz99 in forum Excel Help
    Replies: 1
    Last Post: 08-22-2012, 09:19 PM
  5. Formatting Problem while copying data
    By princ_wns in forum Excel Help
    Replies: 3
    Last Post: 04-03-2012, 07:18 PM

Posting Permissions

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