Сортировка по разным символам валюты в Excel 2010

1925
JennieB

Бухгалтерия вводит денежные поступления в разных валютах (в долларах, шекелях и австралийских фунтах). Можно ли отсортировать столбец, содержащий смешанные валюты, по типу валюты, если символ валюты содержится в той же ячейке с суммой, или символ валюты должен находиться в отдельном столбце от денежной суммы?

1
Я не могу понять ... для пояснения, что содержится в колонке, которую нужно отсортировать? Цифровые значения в формате валюты или текстовые значения, содержащие символ валюты и цифры? danicotra 8 лет назад 1
@danicotra: похоже, вот в чем вопрос - можно ли сортировать составной столбец или символ валюты должен находиться в отдельном столбце? fixer1234 8 лет назад 0
Если символ валюты вводится как первый символ в каждом случае, простая сортировка должна сделать это. Если символ не всегда находится в крайнем левом положении символа, я не могу придумать простой способ сделать это без выделения символа в отдельный столбец. fixer1234 8 лет назад 0
Thanx, fixer for your answer. The currency symbol for shekels (nis) follows the number whereas the $ symbol precedes the number. We had figured at work that your suggestion was the way to go but I wanted to see if there was an alternative. JennieB 8 лет назад 0
@ fixer1234 и JennieB: ОСТОРОЖНО, вы не можете просто добавить символ валюты к значениям суммы, см. мой последний комментарий к ответу. danicotra 8 лет назад 0

1 ответ на вопрос

0
danicotra

PREAMBLE: I didn't understand your question at first but then I realized you can't be dealing with text values (currency symbol + digits) for this, so you need to be dealing with cells containing values formatted so that they show as currency amounts but that actually contains only numbers (simply digits, no currency symbols).

Well, since Excel still doesn't provide a sorting based upon cells formatting (besides of colors/icons) at this time, the only solution that comes to my mind is basically the second you hypothesized: you need to put a relative currency symbol for each amount (row) in a secondary column; that way you could then do a custom multi-level sorting (first-level on the currency column and second-level on the amount column) and get your data sorted out.

What I can do, now, is suggesting you a way to automate the process so to make things faster and assuming you don't want to do things like writing currency symbols for every amount row by hand (do you? ;-D).

OK, so if you can use VBA for this, here we go...

1) Put the following VBA code in a module:

Public Function GetCurrency(ByVal r As Range) As String Application.Volatile Static RegX As Object If RegX Is Nothing Then Set RegX = CreateObject("VBScript.RegExp") With RegX .Global = True .Pattern = "[0-9\-\.,\s]" GetCurrency = .Replace(r.Text, "") End With End Function 

2) Now, assuming amounts values are in column "A" and currency symbols shall be on column "B", put this formula in the first column B row (B1 cell):

=GetCurrency(A1) 

then copy that formula down for all the needed subsequent rows of the same column (B).

OK so, by now, you got the two columns, the one with formatted amount values (A) the other one you needed containing the relative currency symbols (B).

PLEASE NOTE THIS WILL WORK ONLY IF MY PREAMBLE ASSUMPTIONS ARE MET AND THEREFORE YOU HAD COLUMN "A" CONTAINING NUMERIC VALUES FORMATTED AS PROPER CURRENCIES. IF NOT, HAVING TO MANUALLY FORMAT EACH COLUMN "A" ROW/CELL AT THIS POINT MAKES NO DIFFERENCE AND NO BENEFIT/GAIN OVER THAN DIRECTLY WRITING CURRENCY SYMBOL BY HAND ON EACH COLUMN "B" ROW/CELL

3) Now select the two columns and do the custom multi-level sort:

Go to "Data" ribbon, look for "Sort & Filter" group, click "Sort";

Sort COLUMN B VALUES (first level)

Click on "Add Level"

Sort COLUMN A VALUES (second level)

and... you're done!

P.S.: Now, if you wish, you can even safely hide the "B" column.

REFS: More on multi-column based sorting.


IMPORTANT FINAL NOTE:

you don't have to manipulate/modify in no way the values in the amounts column, currency symbols NEED TO BE in a secondary column for this. You can't just add currency symbols to your amount values column 'cause, otherwise, you'll get amount as text values and therefore won't be able to sort them properly as numeric values would! (Think, for example, about what happens when you have "$80", "$30", "$500" as text values: "$500" will be sorted between "$80" and "$30" because as chars: "8" < "5" < "3" ...Hope you got it.)

@JennieB: Я задержался, потому что хотел быть уверенным в потенциале Excel по возможностям сортировки по форматированию ячеек (... у него есть функции, которые Calc по-прежнему не предоставляет, но, как я уже сказал, они связаны только с цветами / значками и не больше.) danicotra 8 лет назад 0
Я не уверен, насколько хорошим предположением является то, что символ валюты только форматирует. Похоже, что он вводится вручную, что делает текстовые строки ввода, если Excel не понимает и не обрабатывает его как форматирование. Было бы хорошо получить некоторую информацию от ОП. fixer1234 8 лет назад 0

Похожие вопросы