问题描述
 
我需要vba代码中的以下要求方面的帮助。我已经给出了源输入和源输出。
对于每个表名,例如Tablename具有值"Dest - > Destnumber - > idno",然后我的源输出应该如下所示。任何人都可以帮助实现vba代码。
Hi,
I need help on below requirement in vba code. I have given source input and source output.
For each tablename, say Tablename has value "Dest -> Destnumber -> idno", then my source output should be like below. Can anyone help on to achieve in vba code.
输入:
输出:
推荐答案
Sub tet()
Dim myList As ListObject
设置myList = ActiveSheet.ListObjects(" Tablename")
Ncolumns = myList.ListColumns.Count
Nlines = myList.ListRows.Count
For i = 1 To Nlines
如果myList.Range(i,1)=" Dest"然后
myList.Range(i,2)=" Destnumber"
myList.Range(i,3)=" idno"
ElseIf myList.Range(i,1)=" Test"然后
myList.Range(i,2)=" Testnumber"
myList.Range(i,3)=" unqno"
结束如果
下一页i
结束分
数
Sub tet()
Dim myList As ListObject
Set myList = ActiveSheet.ListObjects("Tablename")
Ncolumns = myList.ListColumns.Count
Nlines = myList.ListRows.Count
For i = 1 To Nlines
If myList.Range(i, 1) = "Dest" Then
myList.Range(i, 2) = "Destnumber"
myList.Range(i, 3) = "idno"
ElseIf myList.Range(i, 1) = "Test" Then
myList.Range(i, 2) = "Testnumber"
myList.Range(i, 3) = "unqno"
End If
Next i
End Sub
这篇关于VBA代码中的要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!