ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel VBA - Check/Format String (https://www.excelbanter.com/excel-discussion-misc-queries/53996-excel-vba-check-format-string.html)

magix

Excel VBA - Check/Format String
 
Hi,

I would like to check and format string from a cell if a condition is met,
via using macro button.
Condition: if there is apostrophe in that string, the following letter
after apostrophe must be lowercase. if the following letter is a space, then
nothing happen.

Of course, if I select multiple cells, it will check each of them.

Thanks in advance.

Regards,
Magix



Bob Phillips

Excel VBA - Check/Format String
 

Dim cell As Range
Dim iPos As Long

For Each cell In Selection
iPos = InStr(cell.Value, ",")
If iPos 0 Then
cell.Value = Left(cell.Value, iPos) & _
UCase(Mid(cell.Value, iPos + 1, 1)) & _
Right(cell.Value, Len(cell.Value) - iPos -
1)
End If
Next cell


--

HTH

RP
(remove nothere from the email address if mailing direct)


"magix" wrote in message
...
Hi,

I would like to check and format string from a cell if a condition is met,
via using macro button.
Condition: if there is apostrophe in that string, the following letter
after apostrophe must be lowercase. if the following letter is a space,

then
nothing happen.

Of course, if I select multiple cells, it will check each of them.

Thanks in advance.

Regards,
Magix






All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com