title: VBA function for call Progress Bar
body: <p>I created a function and a userform for update the % of my progress bar depending of where the code is. But the problem is that the progress bar don't update alone, it updates only when i close it. (it open a new progress bar with the next %)</p>
  <p>This is the userform</p>
  <pre><code>Private Sub UserForm_Activate()
  
      
      UserForm1.Height = 121.5
  
                  progression = taille_progressbar
                  Image_barre.Width = progression * 1.5
                  Label_barre.Caption = progression &amp; &quot;%&quot;
                  DoEvents
  Application.ScreenUpdating = True
      UserForm1.Height = 136.5
  
  End Sub
  </code></pre>
  <p>This is the call</p>
  <pre><code>taille_progressbar = 0
              UserForm1.Show
              
              cn.Open (ConnectionString)
              rs.Open &quot;TRUNCATE Direction_Prix_proxi.prix_crf;&quot;, cn
              rs.Open &quot;TRUNCATE Direction_Prix_proxi.prix_crf_exp;&quot;, cn
              rs.Open &quot;TRUNCATE Direction_Prix_proxi.prix_int_exp;&quot;, cn
              rs.Open &quot;TRUNCATE Direction_Prix_proxi.prix_int_cnt;&quot;, cn
              rs.Open &quot;TRUNCATE Direction_Prix_proxi.prix_u;&quot;, cn
          
                      
              rs.Open &quot;LOAD DATA LOCAL INFILE '\tomatisation\\prix_concurrents.csv&quot; &amp; _
                      &quot;' INTO TABLE direction_prix_proxi.prix_crf FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 2 LINES&quot; &amp; _
                      &quot; (SIGMA, @PRIX) set PRIX= replace(@PRIX, ',','.');&quot;, cn
          
              rs.Open &quot;Delete FROM direction_prix_proxi.prix_crf WHERE (SIGMA = 0);&quot;, cn
              
              rs.Open &quot;UPDATE direction_prix_proxi.matrice_sigma sgm INNER JOIN direction_prix_proxi.prix_crf ref on sgm.SIGMA = ref.SIGMA SET sgm.prix_crf_cty = ref.PRIX;&quot;, cn
              
              
               taille_progressbar = taille_progressbar + 20
              UserForm1.Show
              
                      
              rs.Open &quot;LOAD DATA LOCAL INFILE '\\\\ytkytkykty\\tkkktyytk\\16.Proxi\\Fichiers_automatisation\\prix_concurrents.csv&quot; &amp; _
                      &quot;' INTO jrtjtrjtrjtrjtrjFIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 2 LINES&quot; &amp; _
                      &quot; (@dummy, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy, SIGMA, @PRIX) set PRIX= replace(@PRIX, ',','.');&quot;, cn
          
              rs.Open &quot;Delete FROM jrtrjtrjf_exp WHERE (SIGMA = 0);&quot;, cn
              
              rs.Open &quot;UPDATE rtjtrjtrjtj sgm INNER JOIN direction_prix_proxi.prix_crf_exp ref on sgm.SIGMA = ref.SIGMA SET sgm.prix_crf_exp = ref.PRIX;&quot;, cn
                
               
              taille_progressbar = taille_progressbar + 20
              UserForm1.Show
  
  </code></pre>