|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 714902777 于 2018-9-21 14:06 编辑
我这个是行选的数据,且连续
三种不同的引用格式 2009年10月02日,2009 10 02,2009.10.02
单元格日期引用,并且推5年,再减一天,有办法吗?碰到是1号呢
还有怎么只读取单元格内左读n个字符,并判断是否满足条件
因为我要在引用的文字中间多加几个字,引用了两次
例如 北京001
北京市001
朝阳
朝阳区002
部分代码
Set rng = Application.InputBox(prompt:="Sample", Type:=8)
x = rng.Areas.Count
For Each c In rng.Areas
p = p + 1
r1 = c(1).Row
'c1 = c(1).Column
r2 = c(c.Count).Row
'c2 = c(c.Count).Column
部分代码
For i = r2 To r1 Step -1
Set theDocument = theWord.documents.Open(thePath & "学习证明副本(模板).doc")
With theDocument
For j = 8 To 5 Step -1
theStr = "数据" & j
theTargetStr = arr(i, j + 1)
.ActiveWindow.Selection.homekey unit:=6, Extend:=0
Do
theFindIt = .ActiveWindow.Selection.Find.Execute(findtext:=theStr, Forward:=True)
If theFindIt Then
.ActiveWindow.Selection.text = theTargetStr
.ActiveWindow.Selection.Font.Color = -16777216
.ActiveWindow.Selection.collapse Direction:=0
End If
Loop Until Not theFindIt
Next j
For j = 5 To 1 Step -1
theStr = "数据" & j
theTargetStr = arr(i, j + 1)
.ActiveWindow.Selection.homekey unit:=6, Extend:=0
Do
theFindIt = .ActiveWindow.Selection.Find.Execute(findtext:=theStr, Forward:=True)
If theFindIt Then
.ActiveWindow.Selection.text = theTargetStr
.ActiveWindow.Selection.Font.Color = -16777216
.ActiveWindow.Selection.collapse Direction:=0
End If
Loop Until Not theFindIt
Next j
Application.StatusBar = "正在生成“" & arr(i, 4) & "学习证明副本.doc”…………"
If Len(Dir("C:\Users\Administrator\Desktop\排水户\" & arr(i, 4), vbDirectory)) < 1 Then
MkDir "C:\Users\Administrator\Desktop\排水户\" & arr(i, 4)
End If
pathx = thePathDoc & arr(i, 4) & "\"
DoEvents
.SaveAs Filename:=pathx & arr(i, 4) & "学习证明副本.doc", FileFormat:=0
.Close savechanges:=0
End With
|
|