title: How to use CombBox Value in If Statment in VBA excel?
body: <p><img src="https://i.stack.imgur.com/LDinV.png" alt="enter image description here" /></p>
  <p>I need to update on exist ticket number on VBA in excel</p>
  <p>However, I tried many times to bring the data from the sheet to comboBox of Ticket number from &quot;A2&quot; to lastRow Added, but it tell me its wrong syntax.</p>
  <p>How to take the value of ComboBox
  ? how to insert it in IF statement?
  please help me to make the following condition</p>
  <ol>
  <li>get the ticket number from <strong>Tickets</strong> sheet</li>
  <li>write the update value from combBox <strong>Close by</strong> and <strong>Ticket Status</strong> to both <strong>Ticket</strong> Sheet and remove them from <strong>PendingTickets</strong> sheet if the Ticket status is Solved or Closed</li>
  </ol>
  <p>the code of test If the Ticket Status is Pending or On Progress</p>
  <pre><code>Dim Ws As Worksheet
  Dim lastRow As Long
  Dim openOn As Date
  
  
  'Declare openBy to date Now function'
  openOn = Now()
  'set format function on time var'
  openTimeAmPM = Format(openOn, &quot;m.d.yy h:mm AM/PM&quot;)
  
  
   'copy ticket data to Pending tickst sheet if the ticket status is Pending or On progress'
    '  If SieraForum.CombTicketStatus.Value = &quot;Pending&quot; Or &quot;On Progress&quot; Then
          Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 1).Value = lastRow
          Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 2).Value = SieraForum.txtTicketName.Value
          
          ElseIf SieraForum.ErrorOption = True Then
           Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 3).Value = &quot;Error&quot;
          ElseIf SieraForum.OrderOption = True Then
           Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 3).Value = &quot;Order&quot;
          
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 4).Value = SieraForum.CombSeverity.Value
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 5).Value = SieraForum.CombLocation.Value
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 6).Value = SieraForum.txtTicketDetails.Value
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 7).Value = SieraForum.CombOpenBy.Value
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 8).Value = SieraForum.CombCloseBy.Value
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 9).Value = SieraForum.CombTicketStatus.Value
              Sheets(&quot;PendingTickets&quot;).Cells(lastRow + 1, 10).Value = openTimeAmPM
      
      Else
           MsgBox &quot;The Ticket is Added Successfully&quot;
      End If
           
      
  </code></pre>
  <p>the Code of Save Button on Tap <strong>Update Ticket</strong></p>
  <pre><code>    Private Sub btnSave2_Click()
   
      'declare close on date function'
       Dim closeOn As Date
       
       ' set format function on time var'
       closeOn = Now()
       closeTimeAmPM = Format(openOn, &quot;m.d.yy h:mm AM/PM&quot;)
      
       
      'To enter new line'
      lastRow = WorksheetFunction.CountA(Sheets(&quot;Tickets&quot;).Range(&quot;A:A&quot;))
      Sheets(&quot;Tickets&quot;).Cells(lastRow + 1, 1).Value = lastRow
       
      Sheets(&quot;Tickets&quot;).Cells(lastRow + 1, 8).Value = SieraForum.CombCloseBy.Value
      Sheets(&quot;Tickets&quot;).Cells(lastRow + 1, 9).Value = SieraForum.CombTicketStatus2.Value
      'write the update statement'
      'Sheets(&quot;Tickets&quot;).Cells(lastRow + 1, 12).Value = &quot;Update Statement &gt; &quot; + SieraForum.txtTicketUpdate.Value
      Sheets(&quot;Tickets&quot;).Cells(lastRow + 1, 11).Value = closeTimeAmPM
              
      'Clear the data from the form'
      SieraForum.CombTicketNum.Value = &quot;&quot;
      SieraForum.CombCloseBy = &quot;&quot;
      SieraForum.CombTicketStatus2 = &quot;&quot;
      SieraForum.txtTicketUpdate.Value = &quot;&quot;
  
  End Sub
  </code></pre>