microsoft-excel-training - macros
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and Help » microsoft-excel-training - Macros

microsoft-excel-training - Macros

The UK's most regular instructor-led training courses.
Training information: microsoft-excel-training · Excel training courses · VBA courses London

resolvedResolved · Low Priority · Version Standard

Macros

Martin has attended:
Excel Intermediate course
Excel Advanced course
Excel VBA course

by - delegate Martin [9 posts] (2007 Nov 20 Tue, 16:28) replyReply

Very long List of currencies (eg EDM,EAT etc have to be changed to EUR.how can a macro be written to do this?

Excel Advanced 1 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2002/XP 2008 Sep 10 Wed Tooting 0 FULL    
2003 2008 Sep 10 Wed Bloomsbury 5 book now £219 £235
2003 2008 Sep 12 Fri Southwark 5 book now £219 £235
2003 2008 Sep 17 Wed Southwark 0 FULL    
2003 2008 Sep 17 Wed Bayswater 5 book now £195 £205
2003 2008 Sep 19 Fri Bloomsbury 6 book now £214 £230
Full Schedule: See all 125 Excel Advanced course dates.
Bookings currently available until 24th November 2009.

Replacing Multiple Currencies Macro

by - trainer Carlos gold contributer[413 posts] (2007 Nov 21 Wed, 16:35) replyReply

Martin

Do the following:

1. Select the range of currencies to be changed to "EUR"

2. Run the following macro (maybe attached to a button)

Sub ReplaceCurrency()

Selection.Replace What:="*", Replacement:="EUR", LookAt:=xlPart, SearchOrder:=xlByRows

End Sub


Hope this helps

Carlos

RE: Replacing Multiple Currencies Macro

by - delegate Martin [9 posts] (2007 Nov 21 Wed, 16:43) replyReply

Hi Carlos,
Ran the macro and it replaced all the cells with EUR.
I want to replace only the items in column 9 which begin with the letter E
Many thanks
Regards
Martino

RE: Replacing Multiple Currencies Macro

by - trainer Carlos gold contributer[413 posts] (2007 Nov 21 Wed, 17:18) replyReply

Martin

To do that, in the above code add an "E" to the what line as seen below

What:="E*"

This will only replace names starting with E

Carlos

RE: Replacing Multiple Currencies Macro

by - delegate Martin [9 posts] (2007 Nov 21 Wed, 17:33) replyReply

I entered the code below but nothing happened at all
Sub ReplaceCurrency()

Selection.Replace What:="E*", Replacement:="EUR", LookAt:=xlPart, SearchOrder:=xlByRows

End Sub

RE: Replacing Multiple Currencies Macro

by - trainer Carlos gold contributer[413 posts] (2007 Nov 22 Thu, 09:53) replyReply

Martin

You need to attach the macro to a button on a toolbar or on the Worksheet.

Then you need to manually Select the range of names that need to change and click the button.

To Automatically select the names insert a line, just after the Sub line, to select the required range eg Range ("K3:K100").Select

Carlos

RE: Replacing Multiple Currencies Macro

by - delegate Martin [9 posts] (2007 Nov 22 Thu, 10:56) replyReply

thanks Carlos
That works much better. However it is now changing SEK into SEUR. I want only currencies begunning with E to be changed to EUR. Is there a way to achieve this?
Regards
Martin

RE: Replacing Multiple Currencies Macro

by - trainer Carlos gold contributer[413 posts] (2007 Nov 23 Fri, 10:17) replyReply

Martin

When I tested the code I gave you I didn't test for that. The replace function replaces ALL instances of the text.

To get around that you need to check if the first letter if the text is an "E" and only then use replace. The code below should resolve the problem:

Sub ReplaceCurrency()

Dim iColumn As Integer 'The Numeric value of the column of the Active Cell
Dim NumRows As Integer 'The number of rows with data
Dim Counter As Integer 'The Counter used to indicate the new cell being checked
Dim MyCurrency As String 'The Currency value being checked

'Select the first cell of the currency column

iColumn = ActiveCell.Column

NumRows = ActiveCell.CurrentRegion.Rows.Count

For Counter = 2 To NumRows

MyCurrency = Cells(Counter, iColumn).Value

If Left(MyCurrency, 1) = "E" Then

Cells(Counter, iColumn).Select
Selection.Replace What:="*", Replacement:="EUR", LookAt:=xlPart, SearchOrder:=xlByRows

End If

Next Counter

End Sub


Carlos

RE: Replacing Multiple Currencies Macro

by - delegate Martin [9 posts] (2007 Nov 23 Fri, 11:17) replyReply

Thanks Carlos that's perfect!


Related articles

· Customized Financial Excel Courses in London
· Features of Microsoft Excel that assist in Analysis of Financial Data
· Microsoft Office and the Small Business: Part 1 Excel
· Fun Things I've Done With Excel
· Microsoft Excel Training Course

Excel tip:

Select Single Data Marker

To select a single data marker in a chart, ie line, bar or column;
After you have pressed Ctrl+Click (to select the entire chart) you can press the Up or Down arrows to select a data series, then press the Left or Right arrow to select a data point within that series.

View all Excel hints and tips

Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz