常用短句 活动工作表最后一行
常用情况
m = range(“a65536”).end(xlup).row
最大下限
m = range(“a” & rows.count).end(xlup).row
屏幕闪烁
关闭
Application.ScreenUpdating = False
打开
Application.ScreenUpdating = True
警告提示
关闭
Application.DisplayAlerts = False
打开
Application.DisplayAlerts = True
工作表隐藏
深度隐藏
Sheet5.Visible = xlSheetVeryHidden
普通隐藏
Sheet5.Visible = false
取消隐藏
Sheet5.Visible = True
审阅密码
加密
Sheets(“sheet1”).Protect (“123456”)
解密
Sheets(“sheet1”).Unprotect (“123456”)
透视表刷新
Sheet1.PivotTables(“数据透视表1”).PivotCache.Refresh
指定单元格添加批注
Sheet1.Cells(1, 1).AddComment Text:=”批注内容”
定点执行
Application.OnTime TimeValue(“04:00:00”), “MySub”
选择文件窗口
Filename = Application.GetOpenFilename(“Excel文件(*.xlsm & .xlam & .xlt), .xlsm; .xlam;*.xlt”, , “VBA破解”)
功能性模块 遍历文件夹全部工作簿的全部工作表 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 mypath = ThisWorkbook.Path & "\123\" myfile = Dir(mypath & "*.xls" ) Do While myfile <> "" If myfile <> ThisWorkbook.Name Then Set ak = Workbooks.Open(mypath & myfile) Else GoTo tiaozhuan End If For i = 1 To ActiveWorkbook.Worksheets.Count With ak.Worksheets(i) nm = ak.Name nm2 = .Name n = .Range("a65536" ).End (xlUp).Row pp = .Range("a2:s" & n) n = n - 1 Sheet1.Range("a" & m + 1 & ":s" & m + n) = pp Sheet1.Range("t" & m + 1 & ":t" & m + n) = nm & nm2 m = m + n End With Next i ak.Close myfile = Dir Loop tiaozhuan:
outlook邮件一键发送 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Set OLApp = CreateObject("Outlook.application" )Set OLMail = OLApp.CreateItem(0 )OLApp.Session.Logon na = ThisWorkbook.Name pa = ThisWorkbook.Path With OLMail .To = "qqqqqqqqqqqq@qq.com;asasasas@qq.com" .CC = "" .BCC = "" .Subject = na .Body = "邮件仅为测试" .Attachments.Add (pa & "\" & na) pdy = Msgbox("是否田间邮件正文内容?" , vbYesNo) if pdy = vbNo Then .send Else .display endif End With
通过百度计算两城市间公里数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Sub test()Set JS = CreateObject("msscriptcontrol.scriptcontrol" )JS.Language = "JavaScript" With CreateObject("WinHttp.WinHttpRequest.5.1" )For i = 2 To Sheet1.Range("a65536" ).End (xlUp).Rows1 = JS.Eval("encodeURIComponent('" & Sheet1.Cells(i, 1 ) & "');" ) s2 = JS.Eval("encodeURIComponent('" & Sheet1.Cells(i, 3 ) & "');" ) .Open "GET" , "http://map.baidu.com/?newmap=1&reqflag=pcmap&biz=1&qt=nav&c=1&sn=2$$$$$$" & s1 & "$$0$$$$&en=2$$$$$$" & s2 & "$$0$$$$" , False .Send tt = .responsetext Sheet1.Cells(i, 6 ) = Val(Split(Split(tt, ":" )(2 ), "," )(0 )) / 1000 Next iEnd With End Sub