Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2228|回复: 3

[已解决]关于获取变量中信息后选择字符问题,求各位帮帮忙谢谢。

[复制链接]
发表于 2015-3-5 15:50 | 显示全部楼层 |阅读模式
本帖最后由 ccc919 于 2015-3-5 15:52 编辑

假如 X变量已经获取到数值
X 变量获取到的值为:C:\Documents and Settings\Administrator\AppData\23.xls
请问如何 C:\Documents and Settings\Administrator\AppData 提取标记为红色的字符,不读取23.xls字符
形成的新变量应该为 C:\Documents and Settings\Administrator\AppData
最佳答案
2015-3-5 15:57
  1. Sub Macro1()
  2. x = "C:\Documents and Settings\Administrator\AppData\23.xls"
  3. y = Split(x, "")
  4. MsgBox Replace(x, "" & y(UBound(y)), "")
  5. End Sub
复制代码
发表于 2015-3-5 15:57 | 显示全部楼层    本楼为最佳答案   
  1. Sub Macro1()
  2. x = "C:\Documents and Settings\Administrator\AppData\23.xls"
  3. y = Split(x, "")
  4. MsgBox Replace(x, "" & y(UBound(y)), "")
  5. End Sub
复制代码
回复

使用道具 举报

发表于 2015-3-5 15:59 | 显示全部楼层
  1. Sub tt()
  2.     x = "C:\Documents and Settings\Administrator\AppData\23.xls"
  3.     xrr = Split(x, "")
  4.     x = Left(x, Len(x) - Len(xrr(UBound(xrr))) - 1)
  5.     MsgBox x
  6. End Sub
复制代码
回复

使用道具 举报

发表于 2015-3-5 16:40 | 显示全部楼层
  1. Sub pp()
  2. x = "C:\Documents and Settings\Administrator\AppData\23.xls"
  3. n = InStrRev(x, "") - 1
  4. y = Left(x, n)
  5. MsgBox y
  6. End Sub
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-3-29 22:35 , Processed in 0.465810 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表