摘要: Sub 合并工作簿() Dim my_path, my_file As String Dim ws As Worksheet Dim wb As Workbook Dim twb As Workbook Set twb = ThisWorkbook '设置twb 为当前代码所在工作簿 my_path = "C:\Users\queqiaoshui\Desktop\excel\" & "*... 阅读全文
posted @ 2019-01-15 10:36 queqiaoshui 阅读(290) 评论(0) 推荐(0) 编辑
摘要: Sub 拆分工作簿并命名() Dim mypath As String Dim sh As Worksheet Dim file_name As String mypath = ThisWorkbook.Path For Each sh In Worksheets sh.Copy '这条语句会复制工作表并放在一个新建工作簿 file_name = ActiveWorkboo... 阅读全文
posted @ 2019-01-14 14:57 queqiaoshui 阅读(1429) 评论(0) 推荐(0) 编辑
摘要: Sub 批量增加工作表() Dim i As Integer For i = 1 To 10 '每次都在最后一张表后面增加 Worksheets.Add after:=Sheets(Worksheets.Count), Count:=1 ActiveSheet.Name = Sheet1.Range("a" & i).Text '提取单元格文本用作新工作表名 ... 阅读全文
posted @ 2019-01-14 09:23 queqiaoshui 阅读(1471) 评论(0) 推荐(0) 编辑
摘要: Sub gongzuobu() Dim wb As Workbook Set wb = Workbooks("工作簿1.xltm") ' 打开某个工作簿 Set wb = Workbooks(1) '打开第一个工作簿 Set wb = ActiveWorkbook '打开活动工作簿 Set wb = ThisWorkbook '打开代码所在工作簿 MsgBox... 阅读全文
posted @ 2019-01-13 19:51 queqiaoshui 阅读(210) 评论(0) 推荐(0) 编辑
摘要: Sub gongzuobu() Dim my_path As String Dim wb As Workbook Dim num As Integer Set wb = Workbooks("工作簿1.xltm") '建立工作簿对象 Set wb = Workbooks(1) Set wb = ActiveWorkbook Set wb = ThisWorkbook 'MsgBox wb.Na... 阅读全文
posted @ 2019-01-13 15:11 queqiaoshui 阅读(354) 评论(0) 推荐(0) 编辑
摘要: sub demo() dim x as integer x = instr (1, "abcedfg","f") '从第一个位置开始查找"f"在"abcdefg"中位置,此时返回6 if instr(1, "abcedfg","f") then '如果条件为真,则执行以下语句 阅读全文
posted @ 2019-01-13 09:13 queqiaoshui 阅读(1863) 评论(0) 推荐(0) 编辑
摘要: Sub demo45() Dim ws As Worksheet ‘把ws 定义为一个工作表对象 For Each ws In Worksheets '用for each 遍历对象集合 ws.Name = "哈哈" & ws.Name ’改名 Next End Sub 阅读全文
posted @ 2019-01-13 08:53 queqiaoshui 阅读(2211) 评论(0) 推荐(0) 编辑
摘要: Sub huoquqiqi() Dim g_year As Integer Dim g_month As Integer Dim g_days As Integer g_year = Year(Now) '时间函数,获取当前时间的年份 g_month = Month(Now) If g_month = 2 Then '当二月份时,判断当前年份是否为闰年 If g_year... 阅读全文
posted @ 2019-01-13 08:35 queqiaoshui 阅读(7783) 评论(0) 推荐(0) 编辑
摘要: Sub demo() ' select case 练习 Dim card As String Dim i As Integer For i = 1 To 14 card = Range("a" & i) Select Case card Case "j" Range("b" & i) = "一等奖" Case "q" ... 阅读全文
posted @ 2019-01-12 10:57 queqiaoshui 阅读(1143) 评论(0) 推荐(0) 编辑
摘要: Option Explicit Sub chengfabiao() Dim i As Integer '声明变量 Dim j As Integer For i = 1 To 9 '循环嵌套 For j = 1 To i Cells(i, j) = j & "x" & i & "=" & i * j Cells(i,... 阅读全文
posted @ 2019-01-12 10:37 queqiaoshui 阅读(559) 评论(0) 推荐(0) 编辑