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

I wonder if anyone knows how to have a column in Excel 2003
automatically formatted to a particular currency when this particular
currency is selected from a drop down list in another cell?

i.e,;

Cell H14 has a drop down list to select USD, Canadian or Indonesian
Rupiah.

Cells G20 to G30 contain the Price column that I want to have
automatically formatted to either 2 decimal places for USD currency or
zero decimal places for the Indonesion Rupiah depending on what is
selected in H14.

Should I use a formula to start a macro or something like that.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Auto number formatting

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("H14")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False

Select Case Target.Value
Case "USD"
Me.Range("G20:G30").NumberFormat = "[$USD] #,##0.00"

Case "INR"
Me.Range("G20:G30").NumberFormat = "[$INR] #,##0"

Case "CAD"
Me.Range("G20:G30").NumberFormat = "[$CAD] #,##0.00"

End Select
endit:
Application.EnableEvents = True
End Sub

This is event code. Right-click on the sheet tab and "View code".

Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP

On Thu, 13 Sep 2007 16:23:34 -0700, Randy wrote:

I wonder if anyone knows how to have a column in Excel 2003
automatically formatted to a particular currency when this particular
currency is selected from a drop down list in another cell?

i.e,;

Cell H14 has a drop down list to select USD, Canadian or Indonesian
Rupiah.

Cells G20 to G30 contain the Price column that I want to have
automatically formatted to either 2 decimal places for USD currency or
zero decimal places for the Indonesion Rupiah depending on what is
selected in H14.

Should I use a formula to start a macro or something like that.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Auto number formatting

I'm guessing, given the values produced by the drop-down list, that you
could replace your entire Select Case block with this single line of code...

Me.Range("G20:G30").NumberFormat = "[$" & Target.Value &"] #,##0.00"

Rick


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("H14")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False

Select Case Target.Value
Case "USD"
Me.Range("G20:G30").NumberFormat = "[$USD] #,##0.00"

Case "INR"
Me.Range("G20:G30").NumberFormat = "[$INR] #,##0"

Case "CAD"
Me.Range("G20:G30").NumberFormat = "[$CAD] #,##0.00"

End Select
endit:
Application.EnableEvents = True
End Sub

This is event code. Right-click on the sheet tab and "View code".

Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP

On Thu, 13 Sep 2007 16:23:34 -0700, Randy wrote:

I wonder if anyone knows how to have a column in Excel 2003
automatically formatted to a particular currency when this particular
currency is selected from a drop down list in another cell?

i.e,;

Cell H14 has a drop down list to select USD, Canadian or Indonesian
Rupiah.

Cells G20 to G30 contain the Price column that I want to have
automatically formatted to either 2 decimal places for USD currency or
zero decimal places for the Indonesion Rupiah depending on what is
selected in H14.

Should I use a formula to start a macro or something like that.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Auto number formatting

Probably but OP wants no decimals if the choice is INR

I started with two choices.......USD and INR then realized OP also wanted CAD so
the code just kinda grew.


Gord

On Thu, 13 Sep 2007 22:46:06 -0400, "Rick Rothstein \(MVP - VB\)"
wrote:

I'm guessing, given the values produced by the drop-down list, that you
could replace your entire Select Case block with this single line of code...

Me.Range("G20:G30").NumberFormat = "[$" & Target.Value &"] #,##0.00"

Rick


"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("H14")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False

Select Case Target.Value
Case "USD"
Me.Range("G20:G30").NumberFormat = "[$USD] #,##0.00"

Case "INR"
Me.Range("G20:G30").NumberFormat = "[$INR] #,##0"

Case "CAD"
Me.Range("G20:G30").NumberFormat = "[$CAD] #,##0.00"

End Select
endit:
Application.EnableEvents = True
End Sub

This is event code. Right-click on the sheet tab and "View code".

Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP

On Thu, 13 Sep 2007 16:23:34 -0700, Randy wrote:

I wonder if anyone knows how to have a column in Excel 2003
automatically formatted to a particular currency when this particular
currency is selected from a drop down list in another cell?

i.e,;

Cell H14 has a drop down list to select USD, Canadian or Indonesian
Rupiah.

Cells G20 to G30 contain the Price column that I want to have
automatically formatted to either 2 decimal places for USD currency or
zero decimal places for the Indonesion Rupiah depending on what is
selected in H14.

Should I use a formula to start a macro or something like that.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Auto number formatting

On Sep 14, 10:06 am, Gord Dibben <gorddibbATshawDOTca wrote:
Probably but OP wants no decimals if the choice is INR

I started with two choices.......USD and INR then realized OP also wanted CAD so
the code just kinda grew.

Gord

On Thu, 13 Sep 2007 22:46:06 -0400, "Rick Rothstein \(MVP - VB\)"



wrote:
I'm guessing, given the values produced by the drop-down list, that you
could replace your entire Select Case block with this single line of code...


Me.Range("G20:G30").NumberFormat = "[$" & Target.Value &"] #,##0.00"


Rick


"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("H14")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False


Select Case Target.Value
Case "USD"
Me.Range("G20:G30").NumberFormat = "[$USD] #,##0.00"


Case "INR"
Me.Range("G20:G30").NumberFormat = "[$INR] #,##0"


Case "CAD"
Me.Range("G20:G30").NumberFormat = "[$CAD] #,##0.00"


End Select
endit:
Application.EnableEvents = True
End Sub


This is event code. Right-click on the sheet tab and "View code".


Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP


On Thu, 13 Sep 2007 16:23:34 -0700, Randy wrote:


I wonder if anyone knows how to have a column in Excel 2003
automatically formatted to a particular currency when this particular
currency is selected from a drop down list in another cell?


i.e,;


Cell H14 has a drop down list to select USD, Canadian or Indonesian
Rupiah.


Cells G20 to G30 contain the Price column that I want to have
automatically formatted to either 2 decimal places for USD currency or
zero decimal places for the Indonesion Rupiah depending on what is
selected in H14.


Should I use a formula to start a macro or something like that.- Hide quoted text -


- Show quoted text -


Excuse my ignorance, but could you provide a little more simple
description as I am not a programmer. I am merely an Excel user that
thought he knew a lot about Excel and constantly gets reminded how
little he actually does know! Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Auto number formatting

What do you need to know?

The code when pasted into the sheet module as directed will change the format of
the cells G20:G30 when you choose an item from your dropdown list in H14.

Your dropdown list will contain USD, CAD, INR(I'm guessing that INR is Indian
Rupiah)

The code does not convert the values from USD to CAD or INR, just changes the
format.

If you want an actual conversion you would need to have a list of conversion
factors to reference as well.


Gord

On Fri, 14 Sep 2007 20:09:10 -0700, Randy wrote:

Excuse my ignorance, but could you provide a little more simple
description as I am not a programmer. I am merely an Excel user that
thought he knew a lot about Excel and constantly gets reminded how
little he actually does know! Thanks.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Auto number formatting

Probably but OP wants no decimals if the choice is INR

Damn! I missed the "no decimals" part.

Rick
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Auto number formatting

Probably but OP wants no decimals if the choice is INR

Damn! I missed the "no decimals" part.


Of course, we can still save the one-liner replacement for your Select Case
block...

Me.Range("G20:G30").NumberFormat = "[$" & target.Value & "] #,##0" & _
IIf(target.Value = "INR", "", ".00")


Rick

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
auto number formatting Randy[_4_] Excel Worksheet Functions 0 September 15th 07 12:32 PM
How do I change auto formatting to allow a 0 as the first number britlynd Excel Discussion (Misc queries) 1 August 30th 07 06:51 PM
Auto Number the Rows of Auto Filter Result ashish128 Excel Discussion (Misc queries) 3 April 29th 07 06:41 PM
how to stop excel from auto formatting whole number to decimal % samo New Users to Excel 2 January 31st 07 11:32 PM
Auto Formatting Custom Number CSBUG Excel Discussion (Misc queries) 4 November 17th 05 07:57 PM


All times are GMT +1. The time now is 04:39 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"