EXCEL VBA笔记(不断更新中)
作为一个非IT专业人士,VBA的代码在不停的Google中忘记,为了方便自己查询,特作此笔记用以详细记录在代码中碰到的问题。
如果以下内容侵犯了您的版权,请来信告知,我会立刻删除。如无特殊说明,本笔记遵循《署名-非商业性使用-相同方式共享 2.5 中国大陆》方式进行共享
更新时间:Oct 28, 2011@14:50
Q1.Excel 中命名过的名称在vba中怎么使用
A1. 若某单元格或区域被命名为”aa”,则VBA中引用这个区域,range("aa")
Q2.VBA定义名称
A1.Sheets("工作表名称").range("单元格区域").Name="定义的名称"
Q3.如何在可以运行窗体的同时可以操作EXCEL工作簿(如何在工作表和窗体间切换)
A3.userform1.show vbmodeless
增加一个vbmodeless即可。
来源:http://club.excelhome.net/thread-348925-1-1.html
作者:tonyibm
Q4.获取人名拼音首字母的excel函数
A4.http://blog.jjuv.com/2009/04/19/first-letter-of-the-chinese-names-excel-function.html
Q5.Excel工作簿中工作表分别保存为文件
A5.http://blog.jjuv.com/2009/03/13/excel-worksheet-saved-as-files-separately.html
Q6.如何将excel工作薄中的单列数据复制到不同的新工作簿中
A6.http://blog.jjuv.com/2009/03/10/how-to-excel-in-a-separate-job-thin-data-replication-to-a-different-new-workbook.html
Q7.VBA中获取文件名的方法
A7.http://blog.jjuv.com/2008/03/02/vba-in-the-way-of-access-to-documents.html
Q8.选择性粘贴数值
A8.
ar=ActiveWorkbook.Sheets(1).Columns("L:L")
ThisWorkbook.Sheets("汇总").Columns("E:E")=ar
Q9.如何修改单元格触发宏运行;
A9.例子如下:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim mo As String
If Target.Count > 1 Then Exit Sub
If Target.Address <> "$D$3" Then Exit Sub '(此处地址需用大写)
mo = Target.Value
If mo = 6 Or mo = 12 Then
MsgBox mo & "月需要填写相关资料"
Rows("29:56").Hidden = False
Else
Rows("29:56").Hidden = True
End If
End Sub
Q10.如何取消筛选
A10.AutoFilterMode = False
Q11.判断EXCEL表格中已使用的行数
A11.Sheets("sheet1").UsedRange.Rows.Count
Q12.向单元格中写入公式
A12.普通公式:range("a1")="=sum(a2:a4")"
数组公式:Range("g18").FormulaArray = "=SUM((fa_cat='28-AC1-5'!A18)*(RIGHT(fa_change,2)=""折旧"")*(fa_depr))"
Q13.恢复默认的右键菜单
A13.Application.CommandBars("Cell").Reset '恢复右键菜单
Q14.用VBA判断单元格是否有公式方法
A13.range("a1").HasFormula =True
出处:ExcelHOME
Q15.删除空白行
A13.
Sub DeleteDoubleRow()
Dim d As Object
Dim i As Long, j As Long
Dim arr, s As String
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
arr = Range([a1], Cells(Cells(Rows.Count, 1).End(3).Row, Cells(1, Columns.Count).End(1).Column))
For i = UBound(arr) To 1 Step -1
s = ""
For j = 1 To UBound(arr, 2)
s = s & "-" & arr(i, j)
Next
If d.Exists(s) Then Rows(i).Delete Else d(s) = ""
Next
Set d = Nothing
Application.ScreenUpdating = True
End Sub
Pingback: EXCEL VBA笔记(不断更新中) | 津津有味Jjuv Blog
canadian pharmacy uk delivery
http://expresscanadapharm.com/# Express Canada Pharm
my canadian pharmacy review
A pharmacy that’s globally recognized and locally loved.
cost of generic clomid without insurance
Everything about medicine.
They provide international health solutions at my doorstep.
lisinopril brand name in india
I’m always impressed with their efficient system.
Their global distribution network is top-tier.
gabapentin clinical pharmacology
Their flu shots are quick and hassle-free.
Helpful, friendly, and always patient.
can you take paxil and gabapentin together
Their global outlook is evident in their expansive services.