Need code to skip inactive file while using "Windows(filename.xls).activate" option

naseerrahaman

New Member
Joined
Nov 25, 2012
Messages
8
Office Version
  1. 2019
Hi team,

1.Could any one of you please help me to skip the unavailable / inactive workbooks and go to next code while using the "Windows(filename.xls).activate" code. for example regularly i use to use 15 files with different file name and some time less than 15 files so if i use this option "Windows(filename.xls).activate" for unavailable files it shows error message.

The code should identify and work if file available otherwise should go to next file to perform the task.

2. if we have a 1000 checks in a excel sheet and need to check the status in other file, please help me to code it properly so that the vba should copy one by one and verify the status in other workbook.

Thanks in advance for the help.

Regards,
Rahaman.
Email : naseerrahaman@gmail.com
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi Andrew Poulsom.


I am extremely sorry for the confusion from my side.

Actually daily i will recieve 15 txt files with different name like (1341.txt).....ext. and i have a single file called sourcefile wherein we have given the same file names to the each sheets like 1341..... and my work is to open these txt files in excel to formate it as per requirement and will paste the data in sourcefile with correct sheet name like (1341.txt data will be pasted to sheet 1341).

i am using the code like this
Windows("1341.xls").Activate
Cells.Select
Selection.Copy
Windows("Sourcefiles.xls").Activate
Sheets("1341").Select
Range("A1").Select
ActiveSheet.Paste

some time we recieve less files for eg we get all the files except 1341 file than vba shows error because of unavailabilty of 1341 file.


I hereby request you to kindly help me in this way to skip the files if the files are not opened / unavailable and code should go to next available file.


Thanks in advance for the help.


Regards,

Rahaman.

Email:naseerrahaman@gmail.com

Welcome to MrExcel.

I don't know why you need to refer to a workbook by name rather than looping through the Workbooks collection or why you need to Activate a workbook, but here is a function you can use to check if a workbook is open:

Spreadsheet Page Excel Tips: Some Useful VBA Functions
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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