Get data from dynamic location and filename on closed workbook using VBA

Joe006

New Member
Joined
Nov 20, 2023
Messages
23
Office Version
  1. 2016
Platform
  1. Windows
1700555158018.png


Hi, I got a lot of excel files in different location where each files is put in folder named month and year. I need to get the data from it while it's closed and data is pulled based on the drop down list for the month and the year. I have tried using the INDIRECT function and it work only when the file is opened. I just discovered that need to use VBA script to pull while it closed, if using VBA, how to call the data and set formula for the folder name and file dynamically according the chosen drop down list ?

Any helps much appreciated, Thank you
 
if I change (filPath, 1) this will update link right?

VBA Code:
Set wb = Workbooks.Open(filPath, 1) 'open with not update link
- 0, don’t update
- 1, update external links but not remote links
- 2, update remote links but not external links
- 3, update all links
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi @eiloken , i am currently working to add progress bar during vba code execution, i already create user form, is it right if i put main code at line below in form section? main code got button sub

1701159836034.png


VBA Code:
Private Sub UserForm_Activate()

For i = 1 To 30
For j = 1 To 30
Cells(i, j) = 5 'excel main code put here'?
Next j
UserForm1.Label1.Caption = Str(i) + "% Completed"
UserForm1.Label2.Width = i * 2
UserForm1.Repaint 'Updating Screen
Next i

End Sub

Module 4 code for the progress bar for the form:
Code:
Sub Progress_Bar()

UserForm1.Caption = "Progress Bar"
UserForm1.Label1.Caption = "0% Completed"
UserForm1.Label2.Caption = ""
UserForm1.Label2.BackColor = vbHighlight
UserForm1.Frame1.Caption = ""
Load UserForm1
UserForm1.Show

End Sub
 
Upvote 0
Hi @eiloken , i am currently working to add progress bar during vba code execution, i already create user form, is it right if i put main code at line below in form section? main code got button sub

View attachment 102600

VBA Code:
Private Sub UserForm_Activate()

For i = 1 To 30
For j = 1 To 30
Cells(i, j) = 5 'excel main code put here'?
Next j
UserForm1.Label1.Caption = Str(i) + "% Completed"
UserForm1.Label2.Width = i * 2
UserForm1.Repaint 'Updating Screen
Next i

End Sub

Module 4 code for the progress bar for the form:
Code:
Sub Progress_Bar()

UserForm1.Caption = "Progress Bar"
UserForm1.Label1.Caption = "0% Completed"
UserForm1.Label2.Caption = ""
UserForm1.Label2.BackColor = vbHighlight
UserForm1.Frame1.Caption = ""
Load UserForm1
UserForm1.Show

End Sub
yes, you can, but you can call it from Click event of button too, no need to move it to userform code
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top