swap formula

cemery

New Member
Joined
Apr 23, 2009
Messages
3
I am trying to find a formula or something that will let me swap two cell ranges.

I have a starting range with TRUE and FALSE but I am looking for something that will see "if True swap data between G5 and I5 if G5 is greater than I5, otherwise leave as is."

If some one can help me out it will save me alot of time.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You will need a macro for this, but I'm confused by your description, you say your range contains TRUE and FALSE values, but you are wanting to do a greater than comparison, which sounds like you may have numbers in the cells, which is it?
 
Upvote 0
I have 2 columns with TRUE and False followed by a couple Columns of Dimentions as numbers, and i am looking for a way to make 2 of the columns on numbers to switch places if the seccond column of TRUE and False is TRUE and the first column of numbers is greater than the seccond column of numbers.

Exp.
if TRUE Switch these if
▼ ▼▼ is > ▼▼
▼ ▼ ▼
▼ ▼ ▼
TRUE FALSE 10.5 1.75 5.5
FALSE TRUE 6.5 1.75 2.5
TRUE FALSE 10.5 8.25 1.75
TRUE TRUE 4.85 5.55 5.5
 
Upvote 0
The IF function will return ranges, I don't know your data lay-out but maybe something using this kind of principle will work for you

=SUM(IF(A1=1,B1:B3,C1:C3))
 
Upvote 0
Assumming your sample is columns E:I starting at row 5:

Code:
Sub test()
Dim t As Double, c As Range
For Each c In Range("F5:F" & Range("E" & Rows.Count).End(xlUp).Row)
    If c Then
        If c.Offset(, 1) > c.Offset(, 3) Then
            t = c.Offset(, 3)
            c.Offset(, 3) = c.Offset(, 1)
            c.Offset(, 1) = t
        End If
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top