Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Excel VBA (часть 2)

Модерирует : ShIvADeSt

ShIvADeSt (11-01-2010 10:17): http://forum.ru-board.com/topic.cgi?forum=33&topic=10903  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

ValentinaK

Newbie
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

 Private Sub FindBut_Click()
 
 
    Dim strItemCode As String
     
    Dim lngCurRowIndex As String
    Dim bolFound As Boolean
    Dim objMsgBoxResult As VbMsgBoxResult
    Dim strActualQuantity As String
    Dim strFullQuantity As String
    Dim strCurQuantity As String
    Dim lngRowFound As Long
    Dim strCurNumOfRolls As String
    Dim lngDifference As Long
    Dim strProductName As String
    Dim strUserName As String
     
   
   
        strItemCode = _
        InputBox( _
            "Please insert the item code", _
            "Insert code")
    If (Len(strItemCode) = 0) Then
        Exit Sub
    End If
           
   
     
    strItemCode = UCase(strItemCode) '*****
   ' Spreadsheet1.ActiveCell = Cells(50, 1) '****
     
             
    lngCurRowIndex = c_lngDataFirstRowIndex
    bolFound = False
    Do While Len(GettingKit.Spreadsheet1.Cells(lngCurRowIndex, 1)) > 0
        If (strItemCode = GettingKit.Spreadsheet1.Cells(lngCurRowIndex, 1)) Then
            bolFound = True
            lngRowFound = lngCurRowIndex
        End If
        lngCurRowIndex = lngCurRowIndex + 1
    Loop
     
    If (bolFound = True) Then
        If (GettingKit.Spreadsheet1.Cells(lngRowFound, 5) = "OK") Then
            objMsgBoxResult = _
                MsgBox( _
                    "The quantity is enough. are you sure you want to add?", _
                    vbYesNo + vbQuestion, _
                    "Confirmation")
            If (objMsgBoxResult = vbNo) Then
                Exit Sub
            End If
        End If
     
        strActualQuantity = _
            InputBox( _
                "Please insert the actual quantity of " & strItemCode, _
                "Insert Actual Quantity")
         
        If (Len(strActualQuantity) = 0) Then
            Exit Sub
        End If
        strCurQuantity = GettingKit.Spreadsheet1.Cells(lngRowFound, 3).Select
        GettingKit.Spreadsheet1.Cells(lngRowFound, 3).Font.Color = vbGreen
 
 
     
        If (Len(strCurQuantity) = 0) Then
            GettingKit.Spreadsheet1.Cells(lngRowFound, 3) = strActualQuantity
        Else
            GettingKit.Spreadsheet1.Cells(lngRowFound, 3) = CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 3)) + CLng(strActualQuantity)
        End If
         
        strCurNumOfRolls = GettingKit.Spreadsheet1.Cells(lngRowFound, 4)
        If (Len(strCurNumOfRolls) = 0) Then
            GettingKit.Spreadsheet1.Cells(lngRowFound, 4) = 1
        Else
            GettingKit.Spreadsheet1.Cells(lngRowFound, 4) = CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 4)) + 1
        End If
    Else
        lngRowFound = lngCurRowIndex
        objMsgBoxResult = _
            MsgBox( _
                strItemCode & " doesn't exists. Would you like to add it?", _
                vbYesNo + vbQuestion, _
                "Item doesn't exists")
                 
        If (objMsgBoxResult = vbYes) Then
            strFullQuantity = _
                InputBox( _
                    "Please insert the full qunatity of " & strItemCode, _
                    "Insert Full Quantity")
             
            objMsgBoxResult = _
                MsgBox( _
                    "Are you sure you want to insert item '" & strItemCode & "' with full quantity " & strFullQuantity & "?", _
                    vbYesNo + vbQuestion, _
                    "Confirmation")
                     
            If (objMsgBoxResult = vbYes) Then
                strActualQuantity = _
                    InputBox( _
                        "Please insert the actual qunatity of " & strItemCode, _
                        "Insert Actual Quantity")
                 
                If (Len(strActualQuantity) = 0) Then
                    Exit Sub
                End If
                 
               
                 
                GettingKit.Spreadsheet1.Cells(lngRowFound, 1) = strItemCode
                GettingKit.Spreadsheet1.Cells(lngRowFound, 2) = strFullQuantity
                GettingKit.Spreadsheet1.Cells(lngRowFound, 3) = strActualQuantity
                GettingKit.Spreadsheet1.Cells(lngRowFound, 4) = 1
            End If
        End If
    End If
             
     
 
 
 
If (Len(GettingKit.Spreadsheet1.Cells(lngRowFound, 3)) > 0) Then
 
 
lngDifference = CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 3)) - CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 2))
             
       
            GettingKit.Spreadsheet1.Cells(lngRowFound, 5) = CStr(lngDifference)
        If lngDifference < 0 Then
        GettingKit.Spreadsheet1.Cells(lngRowFound, 5).Font.Color = vbRed
       End If
 
    End If
 
 
End Sub

Всего записей: 13 | Зарегистр. 30-05-2008 | Отправлено: 23:44 28-07-2008
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Excel VBA (часть 2)
ShIvADeSt (11-01-2010 10:17): http://forum.ru-board.com/topic.cgi?forum=33&topic=10903


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru