Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. 'LA SINTASSI DELLA STRINGA DA SPLITTARE E' &Colonna1&Colonna2&Colonna3 ecc...
  3. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  4.   Dim lastAction As String
  5.   Dim cella As String
  6.   Dim ColumnArray() As String
  7.   Dim row_number, i, array_size As Integer
  8.   Dim ws As Worksheet
  9.   Dim tbl As ListObject
  10.   Dim saldoBonus As Integer
  11.  
  12.  
  13. #If Mac Then
  14.     MsgBox ("Scarica la versione per mac perfavore")
  15. #Else
  16.     If Application.CommandBars("Standard").FindControl(ID:=128, recursive:=True).Enabled = True Then
  17.         If (ActiveCell.Column = 5) Then
  18.             lastAction = Application.CommandBars("Standard").FindControl(ID:=128, recursive:=True).List(1)
  19.             If lastAction = Replace(Application.CommandBars("Standard").FindControl(ID:=6002).Caption, "&", "") Then
  20.                 'ATTENZIONE! NOME FOGLIO "Profit"
  21.                Worksheets("LISTA SCOMMESSE").Activate
  22.                 row_number = ActiveCell.Row
  23.                 cella = ActiveCell.Value
  24.                 ColumnArray = Split(cella, "&")
  25.                 Set ws = ActiveSheet 'aggiungo una riga in caso di punta punta'
  26.                Set tbl = ws.ListObjects("LISTABETS")
  27.                 If (Left(cella, 1) = "&") Then 'Il primo carattere deve sempre essere una & commerciale per evitare falsi positiv
  28.                    If (ColumnArray(4) = "P-P") Then
  29.                         tbl.ListRows.Add
  30.                     End If
  31.                     array_size = UBound(ColumnArray) - LBound(ColumnArray)
  32.                     If (ColumnArray(15) = "BR") Then
  33.                         saldoBonus = 1
  34.                     Else
  35.                         saldoBonus = 0
  36.                     End If
  37.                     If (ColumnArray(4) = "P-P") Then
  38.                    
  39.                         cella = ColumnArray(1)
  40.                         Cells(row_number, 5).Value = cella 'copio la data
  41.                        Cells(row_number + 1, 5).Value = cella 'copio la data
  42.                      
  43.                         cella = ColumnArray(2)
  44.                         Cells(row_number, 7).Value = cella 'Scommesse'
  45.                        Cells(row_number + 1, 7).Value = cella 'Scommesse'
  46.                      
  47.                         cella = ColumnArray(3)
  48.                         Cells(row_number, 11).Value = cella 'Book1'
  49.                  
  50.                         cella = ColumnArray(4)
  51.                         Cells(row_number, 12).Value = cella 'scrivo P-P'
  52.                        Cells(row_number + 1, 12).Value = cella 'scrivo P-P'
  53.                      
  54.                         cella = ColumnArray(5)
  55.                         Cells(row_number, 17).Value = cella 'descrizione evento'
  56.                        Cells(row_number + 1, 17).Value = cella 'descrizione evento'
  57.                      
  58.                         cella = ColumnArray(6)
  59.                         Cells(row_number, 18).Value = cella 'Puntata A'
  60.                      
  61.                        
  62.                         cella = ColumnArray(7)
  63.                         Cells(row_number + 1, 11).Value = cella 'book 2'
  64.                      
  65.                         cella = ColumnArray(8)
  66.                         Cells(row_number, 19).Value = cella 'multipla'
  67.                        Cells(row_number + 1, 19).Value = cella 'multipla'
  68.                      
  69.                         cella = ColumnArray(9)
  70.                         Cells(row_number, 21).Value = cella 'data evento'
  71.                        Cells(row_number + 1, 21).Value = cella 'data evento'
  72.                      
  73.                         cella = ColumnArray(10)
  74.                         Cells(row_number, 22).Value = cella 'quota 1'
  75.                        
  76.                         cella = ColumnArray(11)
  77.                         Cells(row_number + 1, 22).Value = cella 'quota 2'
  78.                      
  79.                         cella = ColumnArray(12)
  80.                         Cells(row_number, 26 + saldoBonus).Value = cella  'Importo punta 1'
  81.                      
  82.                         cella = ColumnArray(13)
  83.                         Cells(row_number + 1, 26).Value = cella 'Importo punta 2'
  84.                      
  85.                         cella = ColumnArray(14)
  86.                         Cells(row_number + 1, 18).Value = cella 'Puntata B'
  87.                      
  88.                     Else
  89.                                                 cella = ColumnArray(1)
  90.                         Cells(row_number, 5).Value = cella 'copio la data
  91.                      
  92.                         cella = ColumnArray(2)
  93.                         Cells(row_number, 7).Value = cella 'Scommesse'
  94.                      
  95.                         cella = ColumnArray(3)
  96.                         Cells(row_number, 11).Value = cella 'Book1'
  97.                      
  98.                         cella = ColumnArray(4)
  99.                         Cells(row_number, 12).Value = cella 'scrivo P-B'
  100.                      
  101.                         cella = ColumnArray(7)
  102.                         Cells(row_number, 13).Value = cella 'scrivo Exchange'
  103.                                            
  104.                         cella = ColumnArray(16)
  105.                         Cells(row_number, 14).Value = cella 'scrivo Commisione'
  106.                      
  107.                         cella = ColumnArray(5)
  108.                         Cells(row_number, 17).Value = cella 'descrizione evento'
  109.                      
  110.                         cella = ColumnArray(6)
  111.                         Cells(row_number, 18).Value = cella 'Puntata A'
  112.                      
  113.                         cella = ColumnArray(8)
  114.                         Cells(row_number, 19).Value = cella 'multipla'
  115.                      
  116.                         cella = ColumnArray(9)
  117.                         Cells(row_number, 21).Value = cella 'data evento'
  118.                      
  119.                         cella = ColumnArray(10)
  120.                         Cells(row_number, 22).Value = cella 'quota 1'
  121.                      
  122.                         cella = ColumnArray(11)
  123.                         Cells(row_number, 25).Value = cella 'quota 2'
  124.                      
  125.                         cella = ColumnArray(12)
  126.                         Cells(row_number, 26 + saldoBonus).Value = cella  'Importo punta 1'
  127.                    
  128.                         cella = ColumnArray(13)
  129.                         Cells(row_number, 28).Value = cella 'Importo punta 2'
  130.                    End If
  131.                 End If
  132.      
  133.             End If
  134.         End If
  135.     End If
  136. #End If
  137.  
  138. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement