VBA 含义解释说明(各个步骤) 20
Sub凭证查询()''DimpzbhAsStringDimiAsInteger,jAsInteger,mAsIntegeri=2j=1m=0Sheets("凭证查询")....
Sub 凭证查询()
'
'
Dim pzbh As String
Dim i As Integer, j As Integer, m As Integer
i = 2
j = 1
m = 0
Sheets("凭证查询").Activate
'清空输出区域
Range("d3,f3,h3,C5:H10,h12,f12,d12").Select
Range("E10").Activate
Selection.ClearContents
Cells(1, 1).Select
'接收编号
pzbh = InputBox("请输入查询凭证编号", "凭证查询")
'开始查询输出
Sheets("记账凭单").Select
Do
If m = 1 And Cells(i, 1) <> pzbh Then Exit Do
If Cells(i, 1) = pzbh Then
'凭证借贷方?摘要?现金流项目写入
Worksheets("凭证查询").Cells(4 + j, 3).Value = Range("d" & i).Value
Worksheets("凭证查询").Cells(4 + j, 4).Value = Range("e" & i).Value
Worksheets("凭证查询").Cells(4 + j, 5).Value = Range("g" & i).Value
Worksheets("凭证查询").Cells(4 + j, 6).Value = Range("h" & i).Value
Worksheets("凭证查询").Cells(4 + j, 7).Value = Range("i" & i).Value
Worksheets("凭证查询").Cells(4 + j, 8).Value = Range("k" & i).Value
'凭证日期、单据、审核、制单、记账写入
If Worksheets("凭证查询").Cells(3, 4) = "" Then
Worksheets("凭证查询").Cells(3, 4).Value = Range("a" & i).Value
Worksheets("凭证查询").Cells(3, 6).Value = Range("c" & i).Value
Worksheets("凭证查询").Cells(3, 8).Value = Range("b" & i).Value
Worksheets("凭证查询").Cells(12, 4).Value = Range("n" & i).Value
Worksheets("凭证查询").Cells(12, 6).Value = Range("o" & i).Value
Worksheets("凭证查询").Cells(12, 8).Value = Range("l" & i).Value
m = 1
End If
j = j + 1
End If
i = i + 1
If Cells(i, j) = "" Then
MsgBox "没有此编号的凭证"
Exit Do
End If
Loop
Sheets("凭证查询").Select
End Sub 展开
'
'
Dim pzbh As String
Dim i As Integer, j As Integer, m As Integer
i = 2
j = 1
m = 0
Sheets("凭证查询").Activate
'清空输出区域
Range("d3,f3,h3,C5:H10,h12,f12,d12").Select
Range("E10").Activate
Selection.ClearContents
Cells(1, 1).Select
'接收编号
pzbh = InputBox("请输入查询凭证编号", "凭证查询")
'开始查询输出
Sheets("记账凭单").Select
Do
If m = 1 And Cells(i, 1) <> pzbh Then Exit Do
If Cells(i, 1) = pzbh Then
'凭证借贷方?摘要?现金流项目写入
Worksheets("凭证查询").Cells(4 + j, 3).Value = Range("d" & i).Value
Worksheets("凭证查询").Cells(4 + j, 4).Value = Range("e" & i).Value
Worksheets("凭证查询").Cells(4 + j, 5).Value = Range("g" & i).Value
Worksheets("凭证查询").Cells(4 + j, 6).Value = Range("h" & i).Value
Worksheets("凭证查询").Cells(4 + j, 7).Value = Range("i" & i).Value
Worksheets("凭证查询").Cells(4 + j, 8).Value = Range("k" & i).Value
'凭证日期、单据、审核、制单、记账写入
If Worksheets("凭证查询").Cells(3, 4) = "" Then
Worksheets("凭证查询").Cells(3, 4).Value = Range("a" & i).Value
Worksheets("凭证查询").Cells(3, 6).Value = Range("c" & i).Value
Worksheets("凭证查询").Cells(3, 8).Value = Range("b" & i).Value
Worksheets("凭证查询").Cells(12, 4).Value = Range("n" & i).Value
Worksheets("凭证查询").Cells(12, 6).Value = Range("o" & i).Value
Worksheets("凭证查询").Cells(12, 8).Value = Range("l" & i).Value
m = 1
End If
j = j + 1
End If
i = i + 1
If Cells(i, j) = "" Then
MsgBox "没有此编号的凭证"
Exit Do
End If
Loop
Sheets("凭证查询").Select
End Sub 展开
1个回答
展开全部
Sub 凭证查询() ****过程开始,过程名叫“凭证查询”***
Dim pzbh As String ****定义一个字符型变量pzbh**************
Dim i As Integer, j As Integer, m As Integer ****定义三个整数型变量i,j,m****************
i = 2 ****变量赋值***********************************
j = 1 ****变量赋值***********************************
m = 0 ****变量赋值***********************************
Sheets("凭证查询").Activate ****激活“凭证查询”工作表****************
'清空输出区域
Range("d3,f3,h3,C5:H10,h12,f12,d12").Select ****选择括号内的单元格*********************
Range("E10").Activate ****激活E10单元格,这句可去掉**********
Selection.ClearContents ****清除选定的单元格区域内容************
Cells(1, 1).Select ****选定当前工作表第一行、第一列单元格
'接收编号
pzbh = InputBox("请输入查询凭证编号", "凭证查询")
***调出一个文本输入框,将输入的内容赋值给pzbh****
'开始查询输出
Sheets("记账凭单").Select ****选定“记账凭单”工作表************
Do ****进入Do loop循环*****
If m = 1 And Cells(i, 1) <> pzbh Then Exit Do ****这样写太累了,有需求请HI我。***
If Cells(i, 1) = pzbh Then
'凭证借贷方?摘要?现金流项目写入
Worksheets("凭证查询").Cells(4 + j, 3).Value = Range("d" & i).Value
Worksheets("凭证查询").Cells(4 + j, 4).Value = Range("e" & i).Value
Worksheets("凭证查询").Cells(4 + j, 5).Value = Range("g" & i).Value
Worksheets("凭证查询").Cells(4 + j, 6).Value = Range("h" & i).Value
Worksheets("凭证查询").Cells(4 + j, 7).Value = Range("i" & i).Value
Worksheets("凭证查询").Cells(4 + j, 8).Value = Range("k" & i).Value
'凭证日期、单据、审核、制单、记账写入
If Worksheets("凭证查询").Cells(3, 4) = "" Then
Worksheets("凭证查询").Cells(3, 4).Value = Range("a" & i).Value
Worksheets("凭证查询").Cells(3, 6).Value = Range("c" & i).Value
Worksheets("凭证查询").Cells(3, 8).Value = Range("b" & i).Value
Worksheets("凭证查询").Cells(12, 4).Value = Range("n" & i).Value
Worksheets("凭证查询").Cells(12, 6).Value = Range("o" & i).Value
Worksheets("凭证查询").Cells(12, 8).Value = Range("l" & i).Value
m = 1
End If
j = j + 1
End If
i = i + 1
If Cells(i, j) = "" Then
MsgBox "没有此编号的凭证"
Exit Do
End If
Loop
Sheets("凭证查询").Select
End Sub
Dim pzbh As String ****定义一个字符型变量pzbh**************
Dim i As Integer, j As Integer, m As Integer ****定义三个整数型变量i,j,m****************
i = 2 ****变量赋值***********************************
j = 1 ****变量赋值***********************************
m = 0 ****变量赋值***********************************
Sheets("凭证查询").Activate ****激活“凭证查询”工作表****************
'清空输出区域
Range("d3,f3,h3,C5:H10,h12,f12,d12").Select ****选择括号内的单元格*********************
Range("E10").Activate ****激活E10单元格,这句可去掉**********
Selection.ClearContents ****清除选定的单元格区域内容************
Cells(1, 1).Select ****选定当前工作表第一行、第一列单元格
'接收编号
pzbh = InputBox("请输入查询凭证编号", "凭证查询")
***调出一个文本输入框,将输入的内容赋值给pzbh****
'开始查询输出
Sheets("记账凭单").Select ****选定“记账凭单”工作表************
Do ****进入Do loop循环*****
If m = 1 And Cells(i, 1) <> pzbh Then Exit Do ****这样写太累了,有需求请HI我。***
If Cells(i, 1) = pzbh Then
'凭证借贷方?摘要?现金流项目写入
Worksheets("凭证查询").Cells(4 + j, 3).Value = Range("d" & i).Value
Worksheets("凭证查询").Cells(4 + j, 4).Value = Range("e" & i).Value
Worksheets("凭证查询").Cells(4 + j, 5).Value = Range("g" & i).Value
Worksheets("凭证查询").Cells(4 + j, 6).Value = Range("h" & i).Value
Worksheets("凭证查询").Cells(4 + j, 7).Value = Range("i" & i).Value
Worksheets("凭证查询").Cells(4 + j, 8).Value = Range("k" & i).Value
'凭证日期、单据、审核、制单、记账写入
If Worksheets("凭证查询").Cells(3, 4) = "" Then
Worksheets("凭证查询").Cells(3, 4).Value = Range("a" & i).Value
Worksheets("凭证查询").Cells(3, 6).Value = Range("c" & i).Value
Worksheets("凭证查询").Cells(3, 8).Value = Range("b" & i).Value
Worksheets("凭证查询").Cells(12, 4).Value = Range("n" & i).Value
Worksheets("凭证查询").Cells(12, 6).Value = Range("o" & i).Value
Worksheets("凭证查询").Cells(12, 8).Value = Range("l" & i).Value
m = 1
End If
j = j + 1
End If
i = i + 1
If Cells(i, j) = "" Then
MsgBox "没有此编号的凭证"
Exit Do
End If
Loop
Sheets("凭证查询").Select
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询