Excel VBA使用通配符替换字符串中的字符串 [英] Excel VBA Using wildcard to replace string within string

查看:177
本文介绍了Excel VBA使用通配符替换字符串中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处境艰难,迄今为止找不到解决办法的运气.

I have a difficult situation and so far no luck in finding a solution.

我的VBA收集了像 $ 80,000.50 这样的数字.我试图让VBA删除最后一个句点,使其看起来像 $ 80,000.50 ,但未使用right()

My VBA collects number figures like $80,000.50. and I'm trying to get VBA to remove the last period to make it look like $80,000.50 but without using right().

问题是在上一时期之后有隐藏的空格或字符,这将要处理很多新问题,所以我只是在寻找类似的东西

The problem is after the last period there are hidden spaces or characters which will be a whole lot of new issue to handle so I'm just looking for something like:

replace("$ 80,000.50.",.**.",.**")

在VBA中可以吗?

推荐答案

我无法发表评论,所以....

I cant leave a comment so....

InStrRev呢?

what about InStrRev?

Private Sub this()
    Dim this As String
    this = "$80,000.50."
    this = Left(this, InStrRev(this, ".") - 1)
    Debug.Print ; this
End Sub

这篇关于Excel VBA使用通配符替换字符串中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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