0

enter image description here

Here my example of thing that i will use.

On the left side is the patch it will use NAME BASE REVISE to check the version of package.

Can you convert the script here in to VBA code. I will study about it and integrate to my real work:

if (Patch name = Pack name) then   **** searching for same Name on patch column to reference for patch base and revise number    
       if (base(c column) > base(h column)) ***checknumber[cellbycell] 

           display "yes" in J cell

             or if (base(C column) = base(h column)) then

                    check if revise(D column) > revise(I column)

                      display "yes" in J cell
    else display No

So if you can give me example code ; if you have sometime please explain to me that what each line of code is meaning.

4

3 回答 3

1

像这样的东西应该工作:

Option Explicit

Sub variousconditions()

Dim i As Integer, x As Integer
x = 0
For i = 2 To 10
    With Excel.ThisWorkbook.ActiveSheet
        If .Cells(i, 1) = .Cells(i, 7) Then '****searching for same Name on patch
            Select Case .Cells(i, 3) '***checknumber[cellbycell]
                    Case Is > .Cells(i, 8)
                            .Cells(i, 10) = "yes"
                    Case Is = .Cells(i, 8)
                            If .Cells(i, 4) > .Cells(i, 9) Then
                                .Cells(i, 10) = "yes"
                            End If
                End Select
        End If
    End With
Next i

End Sub

我必须重申 Siddharth 的参考资料,因为它会告诉您需要在哪里保存此代码等:http: //msdn.microsoft.com/en-us/library/office/ee814737%28v=office.14%29 .aspx

于 2013-01-11T07:49:20.920 回答
1

这是一个比较两个点符号版本号的函数,您需要将其粘贴到 VBA 编辑器中的新模块中。

Option Explicit

Public Function VersionCompare(CurrentVersion As Range, _
                               TargetVersion As Range)

    Dim result As Integer
    result = CompareDotStrings(CurrentVersion.Cells(1, 1).Value, _
                               TargetVersion.Cells(1, 1).Value)

    If result = 1 Then
        VersionCompare = True
    Else
        VersionCompare = False
    End If
End Function

Private Function CompareDotStrings(LeftValue As String, _
                                  RightValue As String) _
                                  As Integer

    Dim CompareLeft() As String, CompareRight() As String, CompareLength As Integer

    CompareLeft = Split(LeftValue, ".")
    CompareRight = Split(RightValue, ".")
    CompareLength = UBound(CompareLeft)
    If UBound(CompareRight) < CompareLength Then CompareLength = UBound(CompareRight)

    Dim ElementLeft As Integer, ElementRight As Integer, Comparison As Integer
    Dim ElementNumber As Integer

    For ElementNumber = 0 To CompareLength
        ElementLeft = CInt(CompareLeft(ElementNumber))
        ElementRight = CInt(CompareRight(ElementNumber))
        Comparison = ElementRight - ElementLeft
        If Comparison <> 0 Then
            CompareDotStrings = Sgn(Comparison)
            Exit Function
        End If
    Next ElementNumber
    CompareDotStrings = 0
End Function

有了这个,您可以=VersionCompare(H2, C2)用来比较两个版本号,并且您想要做的所有其他事情(例如拆分虚线版本)都可以使用工作表中的公式来完成。

于 2013-01-11T16:29:25.027 回答
1

您不需要为此使用 vba

=IF($A2=$G2,IF($C2>$H2,"Yes",IF($C2=$H2,IF($D2>$I2,"Yes","No"),"No")),"No")

在 J 列中

于 2013-01-11T07:22:42.123 回答