将首个单词大写,不更改当前大写 [英] Capitalise first letter of words without changing currently Capitalised

查看:53
本文介绍了将首个单词大写,不更改当前大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel和id中有一些文本项,例如大写每个单词的第一个字母.但是,很多文本都包含短语"IT",并且使用当前的大写方法(PROPER)将其更改为"It".有没有办法只将每个单词的首字母大写而不用DE将每个单词的其他字母大写?

Ive got some items of text in Excel and id like to capitalise the first letter of each word. However, a lot of text contains the phrase 'IT' and using current capitalisation methods (PROPER) it changes this to 'It'. Is there a way to only capitalise the first letter of each word without DE capitalising the other letters in each word?

推荐答案

这里是一种VBA方式,将其添加到模块中& = PrefixCaps("A1")

Here is a VBA way, add it to a module & =PrefixCaps("A1")

Public Function PrefixCaps(value As String) As String
    Dim Words() As String: Words = Split(value, " ")
    Dim i As Long
    For i = 0 To UBound(Words)
        Mid$(Words(i), 1, 1) = UCase$(Mid$(Words(i), 1, 1))
    Next
    PrefixCaps = Join(Words, " ")
End Function

这篇关于将首个单词大写,不更改当前大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆