Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default Format portion of formula

I have a person's name. Current format is last name space first name, all in
caps. What I need to do is separate the first and last name, add a comma and
space after the last name then have the first name all in one cell. This is
done, no problems to this point. My problem lies with formatting. I have
been asked to have the first letter of the last and first name in caps and
the rest in lower case. In addition, the full last name needs to be in bold
while the rest of the cell contents are in regular format. I am not real
familiar with the macro world, but I'm not scared of it either if it will
make it easier (it will just have to be spelled out). Formulas I can work
with readily. Can anyone please help with getting this done?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Format portion of formula

You can make the first letters capitalized by using the PROPER formula. As
for bolding only the last name, I don't know of a formula for that-- would
probably have to be a macro, and is beyond my knowhow.
-Ed

"JC" wrote:
I have a person's name. Current format is last name space first name, all in
caps. What I need to do is separate the first and last name, add a comma and
space after the last name then have the first name all in one cell. This is
done, no problems to this point. My problem lies with formatting. I have
been asked to have the first letter of the last and first name in caps and
the rest in lower case. In addition, the full last name needs to be in bold
while the rest of the cell contents are in regular format. I am not real
familiar with the macro world, but I'm not scared of it either if it will
make it easier (it will just have to be spelled out). Formulas I can work
with readily. Can anyone please help with getting this done?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Format portion of formula

Hi,

Try this: insert macros into a general module (you can copy/paste code from
here) and then run the "Test" macro. Change the range as required.

You can invoke VB Editor by Alt+F11, then right click on VBAProject in the
Project window, do Insert--Module and copy/paste this code.

Sub Test() ' test macro
' Reformat cell A1
call ReformatName(range("a1")) ' A! contains cell with name e.g "brown, john"
End


Sub ReFormatName(rng As Range)
If rng.Count = 1 Then ' Single cell
rng.Select
ActiveCell = Application.Proper(ActiveCell)
snl = InStr(1, ActiveCell, ",") - 1 ' Length of surname
ActiveCell.Characters(Start:=1, Length:=snl).Font.FontStyle = "Bold"
End If
End Sub

HTH

"JC" wrote:

I have a person's name. Current format is last name space first name, all in
caps. What I need to do is separate the first and last name, add a comma and
space after the last name then have the first name all in one cell. This is
done, no problems to this point. My problem lies with formatting. I have
been asked to have the first letter of the last and first name in caps and
the rest in lower case. In addition, the full last name needs to be in bold
while the rest of the cell contents are in regular format. I am not real
familiar with the macro world, but I'm not scared of it either if it will
make it easier (it will just have to be spelled out). Formulas I can work
with readily. Can anyone please help with getting this done?

  #4   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default Format portion of formula

This works for one cell. You mentioned I can change the range. How do I do
this? I want to start at cell "F2" and end where the text stops (this is not
a constant end point and will change every time, need to work something in to
select the "F" cells until there is a blank in the range). How do I modify
the macro to do this?

"Toppers" wrote:

Hi,

Try this: insert macros into a general module (you can copy/paste code from
here) and then run the "Test" macro. Change the range as required.

You can invoke VB Editor by Alt+F11, then right click on VBAProject in the
Project window, do Insert--Module and copy/paste this code.

Sub Test() ' test macro
' Reformat cell A1
call ReformatName(range("a1")) ' A! contains cell with name e.g "brown, john"
End


Sub ReFormatName(rng As Range)
If rng.Count = 1 Then ' Single cell
rng.Select
ActiveCell = Application.Proper(ActiveCell)
snl = InStr(1, ActiveCell, ",") - 1 ' Length of surname
ActiveCell.Characters(Start:=1, Length:=snl).Font.FontStyle = "Bold"
End If
End Sub

HTH

"JC" wrote:

I have a person's name. Current format is last name space first name, all in
caps. What I need to do is separate the first and last name, add a comma and
space after the last name then have the first name all in one cell. This is
done, no problems to this point. My problem lies with formatting. I have
been asked to have the first letter of the last and first name in caps and
the rest in lower case. In addition, the full last name needs to be in bold
while the rest of the cell contents are in regular format. I am not real
familiar with the macro world, but I'm not scared of it either if it will
make it easier (it will just have to be spelled out). Formulas I can work
with readily. Can anyone please help with getting this done?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Format portion of formula

Hi,

Change "Sheet1" to whatever your worksheet is called


Sub test()

Dim rng As Range, cell As Range

With Worksheets("Sheet1")

lastrow = Cells(Rows.Count, "F").End(xlUp).Row ' Find last non-blank row in
column F
Set rng = Range("F2:F" & lastrow) ' Set range to all cells from 2 to lastrow
For Each cell In rng ' loop through each cell in range
Call ReFormatName(cell)
Next cell

End With

End Sub


HTH

This works for one cell. You mentioned I can change the range. How do I do
this? I want to start at cell "F2" and end where the text stops (this is not
a constant end point and will change every time, need to work something in to
select the "F" cells until there is a blank in the range). How do I modify
the macro to do this?

"Toppers" wrote:

Hi,

Try this: insert macros into a general module (you can copy/paste code from
here) and then run the "Test" macro. Change the range as required.

You can invoke VB Editor by Alt+F11, then right click on VBAProject in the
Project window, do Insert--Module and copy/paste this code.

Sub Test() ' test macro
' Reformat cell A1
call ReformatName(range("a1")) ' A! contains cell with name e.g "brown, john"
End


Sub ReFormatName(rng As Range)
If rng.Count = 1 Then ' Single cell
rng.Select
ActiveCell = Application.Proper(ActiveCell)
snl = InStr(1, ActiveCell, ",") - 1 ' Length of surname
ActiveCell.Characters(Start:=1, Length:=snl).Font.FontStyle = "Bold"
End If
End Sub

HTH

"JC" wrote:

I have a person's name. Current format is last name space first name, all in
caps. What I need to do is separate the first and last name, add a comma and
space after the last name then have the first name all in one cell. This is
done, no problems to this point. My problem lies with formatting. I have
been asked to have the first letter of the last and first name in caps and
the rest in lower case. In addition, the full last name needs to be in bold
while the rest of the cell contents are in regular format. I am not real
familiar with the macro world, but I'm not scared of it either if it will
make it easier (it will just have to be spelled out). Formulas I can work
with readily. Can anyone please help with getting this done?

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
Replace a portion of a formula krkward Excel Discussion (Misc queries) 3 November 23rd 09 08:11 PM
Format portion of plot area Bob Charts and Charting in Excel 1 February 6th 09 10:28 PM
Return portion of Formula? Ken Excel Discussion (Misc queries) 1 January 8th 09 01:31 PM
A formula for moving a portion of a cell??? McKenna Excel Discussion (Misc queries) 4 February 20th 07 10:23 PM
how do i extend the series of a portion of a formula? fraustrated Excel Worksheet Functions 2 April 21st 05 10:07 PM


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

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

About Us

"It's about Microsoft Excel"