Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Macro for Proper function

Can someone help me write a macro that I could run on spreadsheets that I
need to be sure are in Title Case? I can't figure out how to make the formula
to correct the cell with the information in it.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default Macro for Proper function

Something like this should work for you (just change the ProperRange address
and SheetName assignments in the Const statements to match your actual
conditions)...

Sub MakeProperCase()
Dim R As Range, C As Range
Const ProperRange As String = "D:D"
Const SheetName As String = "Sheet1"
With Worksheets(SheetName)
Set R = Intersect(.Columns(ProperRange), .UsedRange)
For Each C In R
C.Value = StrConv(C.Value, vbProperCase)
Next
End With
End Sub

--
Rick (MVP - Excel)


"stickcc" wrote in message
...
Can someone help me write a macro that I could run on spreadsheets that I
need to be sure are in Title Case? I can't figure out how to make the
formula
to correct the cell with the information in it.
Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Macro for Proper function

Thanks. I copied your macro into the source for the sheet I was working on
but I'm not really sure what to change.
Here's an example of a sheet I am working on:
Sheet name is Financials. (This is sheet 3).
I want to check column A.
What do I put where?

Once I get this figured out (with help!) I'd like to be able to save the
macro to use on other spreadsheets.

"Rick Rothstein" wrote:

Something like this should work for you (just change the ProperRange address
and SheetName assignments in the Const statements to match your actual
conditions)...

Sub MakeProperCase()
Dim R As Range, C As Range
Const ProperRange As String = "D:D"
Const SheetName As String = "Sheet1"
With Worksheets(SheetName)
Set R = Intersect(.Columns(ProperRange), .UsedRange)
For Each C In R
C.Value = StrConv(C.Value, vbProperCase)
Next
End With
End Sub

--
Rick (MVP - Excel)


"stickcc" wrote in message
...
Can someone help me write a macro that I could run on spreadsheets that I
need to be sure are in Title Case? I can't figure out how to make the
formula
to correct the cell with the information in it.
Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Macro for Proper function

You have asked for a macro which Rick has provided...If you are new to macros
launch VBE using Alt+F11. Insert a module. Paste the macro. Modify the
sheetname variable, Range (Rick has referred to column D) to suit your
requirements...Save and get back to workbook. Try running the macro from
Tools|Macro ....and see.


You can also use the worksheet function PROPER(). Try this with A1 = "this
is a test"

=PROPER(A1)

If this post helps click Yes
---------------
Jacob Skaria


"stickcc" wrote:

Thanks. I copied your macro into the source for the sheet I was working on
but I'm not really sure what to change.
Here's an example of a sheet I am working on:
Sheet name is Financials. (This is sheet 3).
I want to check column A.
What do I put where?

Once I get this figured out (with help!) I'd like to be able to save the
macro to use on other spreadsheets.

"Rick Rothstein" wrote:

Something like this should work for you (just change the ProperRange address
and SheetName assignments in the Const statements to match your actual
conditions)...

Sub MakeProperCase()
Dim R As Range, C As Range
Const ProperRange As String = "D:D"
Const SheetName As String = "Sheet1"
With Worksheets(SheetName)
Set R = Intersect(.Columns(ProperRange), .UsedRange)
For Each C In R
C.Value = StrConv(C.Value, vbProperCase)
Next
End With
End Sub

--
Rick (MVP - Excel)


"stickcc" wrote in message
...
Can someone help me write a macro that I could run on spreadsheets that I
need to be sure are in Title Case? I can't figure out how to make the
formula
to correct the cell with the information in it.
Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default Macro for Proper function

Warning

If there are formulas in the range they will be values after you run the macro
Maybe no problem in your case but it is better to use this :

Select the range first before you run ot

Sub Propercase_macro()
Dim selectie As Range
Dim cel As Range
On Error Resume Next
Set selectie = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
If selectie Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each cel In selectie
cel.Value = StrConv(cel.Value, vbProperCase)
Next cel
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Jacob Skaria" wrote in message ...
You have asked for a macro which Rick has provided...If you are new to macros
launch VBE using Alt+F11. Insert a module. Paste the macro. Modify the
sheetname variable, Range (Rick has referred to column D) to suit your
requirements...Save and get back to workbook. Try running the macro from
Tools|Macro ....and see.


You can also use the worksheet function PROPER(). Try this with A1 = "this
is a test"

=PROPER(A1)

If this post helps click Yes
---------------
Jacob Skaria


"stickcc" wrote:

Thanks. I copied your macro into the source for the sheet I was working on
but I'm not really sure what to change.
Here's an example of a sheet I am working on:
Sheet name is Financials. (This is sheet 3).
I want to check column A.
What do I put where?

Once I get this figured out (with help!) I'd like to be able to save the
macro to use on other spreadsheets.

"Rick Rothstein" wrote:

Something like this should work for you (just change the ProperRange address
and SheetName assignments in the Const statements to match your actual
conditions)...

Sub MakeProperCase()
Dim R As Range, C As Range
Const ProperRange As String = "D:D"
Const SheetName As String = "Sheet1"
With Worksheets(SheetName)
Set R = Intersect(.Columns(ProperRange), .UsedRange)
For Each C In R
C.Value = StrConv(C.Value, vbProperCase)
Next
End With
End Sub

--
Rick (MVP - Excel)


"stickcc" wrote in message
...
Can someone help me write a macro that I could run on spreadsheets that I
need to be sure are in Title Case? I can't figure out how to make the
formula
to correct the cell with the information in it.
Thanks!




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Macro for Proper function

Thanks to all three of you for your help. I actually can use both macros now.

"Ron de Bruin" wrote:

Warning

If there are formulas in the range they will be values after you run the macro
Maybe no problem in your case but it is better to use this :

Select the range first before you run ot

Sub Propercase_macro()
Dim selectie As Range
Dim cel As Range
On Error Resume Next
Set selectie = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
If selectie Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each cel In selectie
cel.Value = StrConv(cel.Value, vbProperCase)
Next cel
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Jacob Skaria" wrote in message ...
You have asked for a macro which Rick has provided...If you are new to macros
launch VBE using Alt+F11. Insert a module. Paste the macro. Modify the
sheetname variable, Range (Rick has referred to column D) to suit your
requirements...Save and get back to workbook. Try running the macro from
Tools|Macro ....and see.


You can also use the worksheet function PROPER(). Try this with A1 = "this
is a test"

=PROPER(A1)

If this post helps click Yes
---------------
Jacob Skaria


"stickcc" wrote:

Thanks. I copied your macro into the source for the sheet I was working on
but I'm not really sure what to change.
Here's an example of a sheet I am working on:
Sheet name is Financials. (This is sheet 3).
I want to check column A.
What do I put where?

Once I get this figured out (with help!) I'd like to be able to save the
macro to use on other spreadsheets.

"Rick Rothstein" wrote:

Something like this should work for you (just change the ProperRange address
and SheetName assignments in the Const statements to match your actual
conditions)...

Sub MakeProperCase()
Dim R As Range, C As Range
Const ProperRange As String = "D:D"
Const SheetName As String = "Sheet1"
With Worksheets(SheetName)
Set R = Intersect(.Columns(ProperRange), .UsedRange)
For Each C In R
C.Value = StrConv(C.Value, vbProperCase)
Next
End With
End Sub

--
Rick (MVP - Excel)


"stickcc" wrote in message
...
Can someone help me write a macro that I could run on spreadsheets that I
need to be sure are in Title Case? I can't figure out how to make the
formula
to correct the cell with the information in it.
Thanks!



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
a macro to PROPER text pcor New Users to Excel 4 March 11th 09 12:12 PM
Insert "Proper Function" into existing macro jackel[_14_] Excel Worksheet Functions 10 March 10th 08 04:00 PM
Macro for proper case Tania Excel Discussion (Misc queries) 5 January 25th 06 03:55 PM
Macro won't move in proper progression Laurahoney Excel Discussion (Misc queries) 1 November 23rd 05 07:18 PM
PROPER function MISTY66 Excel Worksheet Functions 1 March 3rd 05 10:16 PM


All times are GMT +1. The time now is 07:00 AM.

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"