VBA with conditions

AdiVohra

New Member
Joined
Aug 31, 2014
Messages
24
Hi,

I have a table as such which was produced by recording a macro. I originally had a large amount of data and filtered out the column called "Der" to only produce anything greater than 5. This produces below.

CurSpoVarClarDerRarLoh
USD-SGD0.6592.32.367.23212.31
USD-THB0.5466.121.2312.32131.31.326
SGD0.953.261.0237.231.3211.0322
GBP1.602314.23.326.5221.6363.322
THB12.563.2140.3212.3251.33.2

<colgroup><col span="3"><col><col><col><col></colgroup><tbody>
</tbody>

After I stopped recording this macro, I now need to add to the VBA so that the output is just the "Der" and "Cur" columns, ignoring the rest. Also, as can be seen, the first 2 rows are given as a currency pair and the last 3 rows are the currency on its own. I only need to output the rows that are presented as a pair (e.g. USD-SGD and not rows with a single currency e.g. SGD) bearing in mind the amount of "paired outputs" may vary from time to time so needs to be open ended to add more?

Hope someone can help
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
If your Data Looks Like This:

Excel 2012
ABCDEFG
1CurSpoVarClarDerRarLoh
2USD-SGD0.6592.32.367.23212.31
3USD-THB0.5466.121.2312.32131.31.326
4SGD0.953.261.0237.231.3211.0322
5GBP1.602314.23.326.5221.6363.322
6THB12.563.2140.3212.3251.33.2
7USD-FGH12.563.2140.3231.33.2
8FGH-GHJ12.563.2140.3221.33.2
9HJK12.563.2140.3211.33.2
10GHJ12.563.2140.3211.33.2
Sheet1

Then use this Code:
Code:
[COLOR=#0000ff]Sub [/COLOR]FilterData()

    [COLOR=#0000ff]Dim [/COLOR]LR [COLOR=#0000ff]As Long[/COLOR]

    LR = Range("A" & Rows.Count).End(xlUp).Row
        ActiveSheet.Range("$A$1:$G$" & LR).AutoFilter Field:=5, Criteria1:=">5", Operator:=xlAnd
        ActiveSheet.Range("$A$1:$G$" & LR).AutoFilter Field:=1, Criteria1:="*-*", Operator:=xlAnd

[COLOR=#0000ff]End Sub[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

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