excel - Progress bar for consolidation loop in VBA -


I have this consolidation macro which opens a sheet, copies and pastes from a sheet of several workbooks on a master sheet, where Data may well be in the thousands of workbooks, in total, this process will take anywhere from 30 meters to one hour and I thought that a progress bar would help.

I got the code I used for the consolidation portion at StackHowfortflow. It was a similar problem, however, the progress bar code I found elsewhere. To fit this for my needs, I had to use a jury-rig code. In the examples, I use the next loop code for the progress bar, which is not mine.

I tried to run my code, but the progress bar does not update. T_T

Can anyone help me with what is wrong in my code? Any help on this is greatly appreciated .. Thanks ..

  Sub OpeningFiles () Dim SelectedFiles FileDialog Dim NumFiles As Long, Long-Term TargetBook Workbook Dim SNAME, sName2, As in the form of the FileIndex Range as a PctCompl single set sName = ThisWorkbook.Sheets ("Sheet1") as sName3. Range ( "J1") SelectedFiles = Application SetupFileDialog (msoFileDialogOpen) set with SelectedFiles .AllowMultiSelect = True .Title = "Select the files you want are strong:" .ButtonName = "" .Filters.Clear .Filters.Add ".xlsx files", "* .xlsx" .Show so SelectedFiles.SelectedItems.Count = 0 then end exit with sub NumFiles = SelectedFiles.SelectedItems.Count FileIndex = 1 now aiming to set NumFiles = Workbooks Open (Selected Files) Selected Items (FileInndex), Readonly: = True) Application. Display Altas = Incorrect Active Workbook Activate Sheets (SNM). Activate error on Gotto 0 range ("D11: J11"). Selection Range (Selection, Selection End (xlDown)). Copy this workbook. Sheet ("Sheet1"). Active range ("B2"). Select if IsEmpty (ActiveCell) = False Then ActiveCell.Offset (1, 0). Choose the limit that the blank (ActiveCell) = True ActiveCell.Paste Paste Special: = xlPasteValuesThisWorkbook.Application.CutCopyMode = False TargetBook.Close SaveChanges: = False Next Failindeks progress pctCompl MsgBox ( "full integration") sub-sub-sub-progress (pctCompl Single form) UserForm1.Text.Caption = pctCompl & amp; "% Complete" UserForm1.Bar.Width = pctCompl * 2 DoEvents End Sub Sub Show Progress () UserForm1.Show End Sub  

Appendix:

This code

  Sheets (Sienam). Activate  

selects the sheets of the open file, in which it is always numbered from 1 to 30. Right now, I have to point that number in a bar. Does it like 3 or 7 times? Like a loop? Like 1-7 or 25-27 .. It is always ascending, so I thought the code below would have to work? ? Consider

  SNAME = sNameStart step sNameEnd to 1 Sheets (SNAME). ("D11: J11") Select range (Selection, Selection.End (xlDown)) .Copy ThisWorkbook.Sheets ("Sheet1"). Active range ("B2"). Select IsEmpty (ActiveCell) = false So what if ActiveCell.Offset (1, 0) IsEmpty (ActiveCell) to .Select end loop = True Then ActiveCell.PasteSpecial Paste: = xlPasteValues ​​ActiveWorkbook.Activate Next SNAME  

Where is the name of the SNAME sheet, sNameStart is the starting sheet and sNameEnd end sheet. However, when I start this code, I get this error. Help?

You need to transfer your call progress pctCompl to your loop inside.

The code you posted progress to pctCompl to next fileindex

  thisWorkbook.Application.CutCopyMode = False TargetBook .Close SaveChanges: = False Next FileIndex Progress pctCompl MsgBox ("Integration Complete!")  

Change it with:

  ThisWorkbook.Application.CutCopyMode = False TargetBook.Close SaveChanges: = False 'Insert your command here' s progress pctCompl Next FileIndex MsgBox ("! Integration Complete")  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -