Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am building a currency exchange table that consists of rates for about 50
countries. The table will be a simple matrix, with all of the countries listed in column A, and then copied and pasted (transposed) in one row. A simple formula in all of the intersecting cells delivers the exchange rate I am interested in. My problem is that I would like to delete all the columns that are not the 4 countries/currencies that will be actual destinations for my company. These 4 a United States, Hungary, China, Euro Lot of info on this board about how to check for zeroes, duplicates, etc..., but nothing I could find on deleting columns based on text headings. Probably a small variation, but I am lost. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
Public Sub DeleteAllBut4Columns() Dim vKeepers As Variant Dim rDelete As Range Dim rCell As Range Dim i As Long Dim bKeep As Boolean vKeepers = Array("United States", "Hungary", "China", "Euro") For Each rCell In Range(Cells(1, 2), _ Cells(1, Columns.Count).End(xlToLeft)) With rCell For i = 0 To UBound(vKeepers) If .Value = vKeepers(i) Then bKeep = True Exit For End If Next i If Not bKeep Then If rDelete Is Nothing Then Set rDelete = .Cells Else Set rDelete = Union(rDelete, .Cells) End If Else bKeep = False End If End With Next rCell If Not rDelete Is Nothing Then rDelete.EntireColumn.Delete End Sub In article , "jmdaniel" wrote: I am building a currency exchange table that consists of rates for about 50 countries. The table will be a simple matrix, with all of the countries listed in column A, and then copied and pasted (transposed) in one row. A simple formula in all of the intersecting cells delivers the exchange rate I am interested in. My problem is that I would like to delete all the columns that are not the 4 countries/currencies that will be actual destinations for my company. These 4 a United States, Hungary, China, Euro Lot of info on this board about how to check for zeroes, duplicates, etc..., but nothing I could find on deleting columns based on text headings. Probably a small variation, but I am lost. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Should i delete heading/subtotal rows when consolidating? | Excel Discussion (Misc queries) | |||
delete the test values, but do not delete the formulas | Excel Discussion (Misc queries) | |||
Macro-delete & move heading | Excel Discussion (Misc queries) | |||
In a table produce an value by column heading and row heading | Excel Worksheet Functions | |||
delete column heading for print | Excel Worksheet Functions |