vbscript VBA - 在Excel中格式化SAP QB数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript VBA - 在Excel中格式化SAP QB数据相关的知识,希望对你有一定的参考价值。

Sub GetIDs()

Dim i As Long
Dim k As Long

k = 2

Sheets("Sheet2").Cells(1, 1).Value = "SI_NAME"
Sheets("Sheet2").Cells(1, 2).Value = "SI_ID"
Sheets("Sheet2").Cells(1, 3).Value = "SI_EMAIL_ADDRESS"
Sheets("Sheet2").Cells(1, 4).Value = "SI_CUID"
Sheets("Sheet2").Cells(1, 5).Value = "SI_LAST_PASSWORD_CHANGE_TIME"
Sheets("Sheet2").Cells(1, 6).Value = "SI_DISABLED"
Sheets("Sheet2").Cells(1, 7).Value = "SI_UPDATE_TS"
Sheets("Sheet2").Cells(1, 8).Value = "SI_USERFULLNAME"
Sheets("Sheet2").Cells(1, 9).Value = "SI_CREATION_TIME"
Sheets("Sheet2").Cells(1, 10).Value = "SI_LASTLOGONTIME"
Sheets("Sheet2").Cells(1, 11).Value = "SI_OWNER"



For i = 3 To 1000000


    If (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_NAME") = 0) Then
        Sheets("Sheet2").Cells(k, 1).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_ID") = 0) Then
        Sheets("Sheet2").Cells(k, 2).Value = Sheets("Sheet1").Cells(i, 2).Value
        
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_EMAIL_ADDRESS") = 0) Then
        Sheets("Sheet2").Cells(k, 3).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_CUID") = 0) Then
        Sheets("Sheet2").Cells(k, 4).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_LAST_PASSWORD_CHANGE_TIME") = 0) Then
        Sheets("Sheet2").Cells(k, 5).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_ALIASES") = 0) Then
        Sheets("Sheet2").Cells(k, 6).Value = Sheets("Sheet1").Cells(i + 2, 4).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_UPDATE_TS") = 0) Then
        Sheets("Sheet2").Cells(k, 7).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_USERFULLNAME") = 0) Then
        Sheets("Sheet2").Cells(k, 8).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_CREATION_TIME") = 0) Then
        Sheets("Sheet2").Cells(k, 9).Value = Sheets("Sheet1").Cells(i, 2).Value
        
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_LASTLOGONTIME") = 0) Then
        Sheets("Sheet2").Cells(k, 10).Value = Sheets("Sheet1").Cells(i, 2).Value
    
    ElseIf (StrComp(Trim(CStr(Sheets("Sheet1").Cells(i, 1).Value)), "SI_OWNER") = 0) Then
        Sheets("Sheet2").Cells(k, 11).Value = Sheets("Sheet1").Cells(i, 2).Value
        

        
        k = k + 1
    
    End If
    
    

Next i

End Sub

以上是关于vbscript VBA - 在Excel中格式化SAP QB数据的主要内容,如果未能解决你的问题,请参考以下文章

vbscript [Excel VBA中的时间戳]在Excel VBA #Excel VBA中创建时间戳字符串

在VBScript文件中集成VBA

vbscript VBA - Excel - Hack受保护的Excel文档或表格(VBA) - 代码

vbscript VBA EXCEL

vbscript vba excel公式相关

vbscript 行和列高度 - Excel(VBA)