首页 > 代码库 > VBA 小知识
VBA 小知识
1. 循环
Dim i As IntegerFor i = 0 To 100 ‘bodyNextWhile i < 100 ‘bodyWend
2. 键值数据结构
‘create dictionary object Set dictMembers = CreateObject("scripting.dictionary") ‘add a key If Not dictMembers.exists(Key) Then ‘add value Dim value(1 To 3) As Integer tempdata(1) = 0 tempdata(2) = 0 tempdata(3) = 0 dictMembers.Add Key, value End If Dim keys() keys = dictMembers.keys ‘read dictionary Dim value For i = 0 To dictMembers.Count - 1 Key = keys(i) value = dictMembers.Item(keys(i)) Me.Cells(i + 1, 2).value = http://www.mamicode.com/value(1) Me.Cells(i + 1, 3).value = http://www.mamicode.com/value(2) Me.Cells(i + 1, 4).value = http://www.mamicode.com/value(3) Next
3. 数据图表chart
‘get the first chart Me.ChartObjects(1).Activate ‘set datasource ActiveChart.SetSourceData Source:=Range("A8:F" & i - 1) While ActiveChart.SeriesCollection.Count > 2 ‘remove useless series ActiveChart.SeriesCollection(1).Delete ActiveChart.SeriesCollection(1).Delete ActiveChart.SeriesCollection(1).Delete Wend ‘display value ActiveChart.SeriesCollection(1).ApplyDataLabels ActiveChart.SeriesCollection(2).ApplyDataLabels
VBA 小知识
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。