Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default convert a formula into a macro

For a variety of reasons I frequently have to convert long columns of text
into text for which the first three characters are in upper case and the rest
of the text string is in lower case.

Example: "Rastafarian" would have to be converted to "RAStafarian".

This is easy enough to do with a formula; i.e.,
=CONCATENATE(UPPER(LEFT(D14,3)),MID(D14,4,1000)) however I would like to
create a macro and attach it to a button so that I can convert these text
strings in one click.

How would I express the above formula in VBA syntax?

Thanks,

Dave
--
Brevity is the soul of wit.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,173
Default convert a formula into a macro

Dave

Something like the below (Works on a selection)

Sub UPPERFirst3()
Dim myCell As Range
For Each myCell In Selection
myCell.Value = UCase(Left(myCell.Value, 3)) & Mid(myCell.Value, 4,
Len(myCell.Value) - 3)
Next myCell
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Dave F" wrote in message
...
For a variety of reasons I frequently have to convert long columns of text
into text for which the first three characters are in upper case and the
rest
of the text string is in lower case.

Example: "Rastafarian" would have to be converted to "RAStafarian".

This is easy enough to do with a formula; i.e.,
=CONCATENATE(UPPER(LEFT(D14,3)),MID(D14,4,1000)) however I would like to
create a macro and attach it to a button so that I can convert these text
strings in one click.

How would I express the above formula in VBA syntax?

Thanks,

Dave
--
Brevity is the soul of wit.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default convert a formula into a macro

Wow, that's great.

Thanks.

Dave
--
Brevity is the soul of wit.


"Nick Hodge" wrote:

Dave

Something like the below (Works on a selection)

Sub UPPERFirst3()
Dim myCell As Range
For Each myCell In Selection
myCell.Value = UCase(Left(myCell.Value, 3)) & Mid(myCell.Value, 4,
Len(myCell.Value) - 3)
Next myCell
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Dave F" wrote in message
...
For a variety of reasons I frequently have to convert long columns of text
into text for which the first three characters are in upper case and the
rest
of the text string is in lower case.

Example: "Rastafarian" would have to be converted to "RAStafarian".

This is easy enough to do with a formula; i.e.,
=CONCATENATE(UPPER(LEFT(D14,3)),MID(D14,4,1000)) however I would like to
create a macro and attach it to a button so that I can convert these text
strings in one click.

How would I express the above formula in VBA syntax?

Thanks,

Dave
--
Brevity is the soul of wit.


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
Reusing formula Tony29 Excel Discussion (Misc queries) 7 September 7th 06 03:34 AM
Convert Excel 4 formula to Excel 2003 format The Gasell Excel Worksheet Functions 3 April 12th 06 05:07 PM
Formula Problem - interrupted by #VALUE! in other cells!? Ted Excel Worksheet Functions 17 November 25th 05 05:18 PM
Macro - formula for end of last row Gary Brown Excel Worksheet Functions 1 June 1st 05 12:02 AM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM


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