Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Update number formatting automatically

Hi
I have tried to find information on this using the search feature but
so far no luck. I have a expense spreadsheet that needs to be able to
display numbers in different currencies. The currency used in each
worksheet is selected from a drop down list. Is it possible to write
a macro that will update a particular range of cells to match the
currency selected from the drop down list? The list is generated from
a separate worksheet which contains the currency formatting in the
cell to the right. I was thinking a macro using a lookup function
could possibly do the trick.

Any help would be greatly appreciated.

Regards

Marcello

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Update number formatting automatically

Marcello,

A lot depends on what exactly you meant by:

"The list is generated from a separate worksheet which contains the currency formatting in the cell
to the right."

Let's say that you have a list of currency format names in one column, and the format string as text
in the next (to the right). And let's say that you have three named ranges: one with the currency
values that need to be formatted (CurrVal), one with the format name and format strings (CurrFormat)
and a single cell with the dropdown (CurrFormSel)

Your macro could be as easy as:

Sub SetCurrFormat()
Range("CurrVal").NumberFormat = Application.Vlookup(Range("CurrFormSel").Value, _
Range("CurrFormat"),2,False)
End Sub

You could also fire this macro through the change event, so that when the value of CurrFormSel
changes, the formats are updated. Copy this code, and put it into the sheet's codemodule.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Name.Name < "CurrFormSel" Then Exit Sub
SetCurrFormat
End Sub


HTH,
Bernie
MS Excel MVP


wrote in message
ups.com...
Hi
I have tried to find information on this using the search feature but
so far no luck. I have a expense spreadsheet that needs to be able to
display numbers in different currencies. The currency used in each
worksheet is selected from a drop down list. Is it possible to write
a macro that will update a particular range of cells to match the
currency selected from the drop down list? The list is generated from
a separate worksheet which contains the currency formatting in the
cell to the right. I was thinking a macro using a lookup function
could possibly do the trick.

Any help would be greatly appreciated.

Regards

Marcello



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Update number formatting automatically

Bernie,

Thanks for the information. The code works well but I have hit upon a
couple of problems. When changing other cells on the worksheet the
change event gives an error, Run-time error '1004': Application-
defined or object-defined error.

Secondly the format strings contain letters that Excel seems to
interpret. For example the Algerian Dinar has the string DZD. Excel
changes the format of the cells to a date format. Is there any way
around this?

Thanks again.

Marcello

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Update number formatting automatically

Further to my recent message, I have change the value of the strings
to 0" DZD". This seems to have corrected the problem with the formats
and allows a space between the string and the number. Would you
recommed using this method?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I automatically update column index number in VLookup whe. Gene Excel Worksheet Functions 2 July 10th 12 11:23 AM
Automatically update a number when printed excelhelp Excel Discussion (Misc queries) 1 April 30th 10 10:58 AM
Update one worksheet tab to automatically update all other tabs? shoechic1 Excel Worksheet Functions 1 May 24th 09 03:55 PM
Automatically update a cell Adriana Excel Worksheet Functions 2 June 8th 07 04:23 AM
automatically update a number in cell when template opens Trampas Excel Discussion (Misc queries) 1 November 30th 05 04:51 PM


All times are GMT +1. The time now is 06:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"