栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

vba for yingying

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

vba for yingying

Dim strNameCase As String
Dim nInputDataStartRow As Integer
Dim nOutputDataTitleRow As Integer
Dim nInputColFunc As Integer
Dim nInputColSubFunc As Integer
Dim nInputColMember As Integer
Dim nInputColValue As Integer
Dim nInputColMemberList As Integer
Dim nInputRowMemberList As Integer
Dim nOUtputdatatitlecol As Integer

Dim lastRow As Integer
Dim lastCol As Integer

Private Sub Init()

'clear sheet bb
'pass

'these will init with find keyword
strNameCase = “案件名”
nInputDataStartRow = 3
nInputColFunc = 2
nInputColSubFunc = 3
nInputColMember = 4
nInputColValue = 5
nInputColMemberList = 3
nInputRowMemberList = 2
nOutputDataTitleRow = 2
nOUtputdatatitlecol = 2
lastRow = 3
lastCol = 3

Sheets(“BB”).Range(“B2”).Value = strNameCase

'init member list
Dim coltmp As Integer
coltmp = nInputColMemberList

Do While Sheets(“Control”).Cells(nInputRowMemberList, coltmp).Value <> “”
Sheets(“BB”).Cells(nOutputDataTitleRow, lastCol).Value = Sheets(“Control”).Cells(nInputRowMemberList, coltmp).Value
lastCol = lastCol + 1
coltmp = coltmp + 1
Loop

End Sub

Function GetOutputRowCase(ByVal strcase As String) As Integer

Dim row As Integer
Dim found As Boolean
found = False
row = nOutputDataTitleRow

Do While row <= lastRow
If Sheets(“BB”).Cells(row, nOUtputdatatitlecol).Value = strcase Then
GetOutputRowCase = row
found = True
End If
row = row + 1
Loop

If Not found Then
GetOutputRowCase = -1
End If

End Function

Function GetOutputColMember(ByVal strMember As String) As Integer

Dim col As Integer
Dim found As Boolean
found = False
col = nOUtputdatatitlecol

Do While col <= lastCol
If Sheets(“BB”).Cells(nOutputDataTitleRow, col).Value = strMember Then
GetOutputColMember = col
found = True
End If
col = col + 1
Loop

If Not found Then
GetOutputColMember = -1
End If

End Function

Private Sub CommandButton1_Click()

Init

'start copy
Dim row As Integer
row = nInputDataStartRow

Dim nOutputRowCase As Integer
Dim nOutputColMember As Integer
Dim strInputCase As String
Dim strInputSubCase As String
Dim strInputMember As String
Dim dInputValue As Double
Dim strcase As String

Do While Sheets(“AA”).Cells(row, nInputColValue).Value <> “”

strInputCase = Sheets("AA").Cells(row, nInputColFunc).Value
strInputSubCase = Sheets("AA").Cells(row, nInputColSubFunc).Value
strInputMember = Sheets("AA").Cells(row, nInputColMember).Value
dInputValue = Sheets("AA").Cells(row, nInputColValue).Value
  
If strInputSubCase <> "" Then
  strcase = strInputSubCase
ElseIf strInputCase <> "" Then
  strcase = strInputCase
Else
  'error
End If

'Get write row
nOutputRowCase = GetOutputRowCase(strcase)
If nOutputRowCase = -1 Then
  nOutputRowCase = lastRow
  lastRow = lastRow + 1
  Sheets("BB").Cells(nOutputRowCase, nOUtputdatatitlecol).Value = strcase
End If

'Get write col
nOutputColMember = GetOutputColMember(strInputMember)
If nOutputColMember = -1 Then
  nOutputColMember = lastCol
  lastCol = lastCol + 1
  Sheets("BB").Cells(nOutputDataTitleRow, nOutputColMember).Value = strInputMember
End If

'Set Value
Sheets("BB").Cells(nOutputRowCase, nOutputColMember).Value = dInputValue

row = row + 1

Loop

End Sub

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/281873.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号