Excel精英培训网

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

[已解决]组合框显示文件名问题求助

[复制链接]
发表于 2011-12-25 15:52 | 显示全部楼层 |阅读模式
2011-12-21_141621.jpg

组合框应用.rar (89.07 KB, 下载次数: 16)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2011-12-25 18:48 | 显示全部楼层    本楼为最佳答案   
  1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  2. If Application.CutCopyMode <> 0 Then Exit Sub
  3. On Error Resume Next
  4. If Target.Address = "$J$3" Then
  5. With ComboBox1
  6. .Visible = True
  7. .Left = Target.Left
  8. .Top = ActiveCell.Top
  9. .Width = ActiveCell.Width * 1
  10. .Height = ActiveCell.Height
  11. .Text = ""
  12. Dim a$, k As Byte, Arr() As String, t$
  13. a = Dir(ThisWorkbook.Path & "\data\*.xls")
  14. If Len(a) Then
  15.     t = a
  16.     Do
  17.         k = k + 1: ReDim Preserve Arr(1 To k)
  18.         Arr(k) = a
  19.         a = Dir()
  20.     Loop Until a = t Or Len(a) = 0
  21. .List() = Arr
  22. End If
  23. End With
  24. Else
  25. Me.ComboBox1.Visible = False
  26. End If

  27. End Sub
复制代码
在事件中添加返回代码就可以了。

评分

参与人数 1 +1 收起 理由
HP2009 + 1 很给力!

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2011-12-26 11:40 | 显示全部楼层
liuguansky 发表于 2011-12-25 18:48
在事件中添加返回代码就可以了。

版主老师最后一个问题,请版主帮忙!{:24:}

请移驾:http://www.excelpx.com/thread-216048-1-1.html
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-14 23:06 , Processed in 0.429377 second(s), 15 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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