VBA to check file name of active workbook

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
168
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

I have a macro that opens a file, calls another macro using the Call statement (Call E_DoRepeatWork_AllWorkbooks).

The called macro does processing and one of the last statements in this macro is to close the active workbook, and then return from where it come from.

What I need to achieve in E_DoRepeatWork_AllWorkbooks is, if the current file name is "12 December" (or even check the first 6 characters, if its faster) then NOT to close the active workbook.

Is what I am asking for possible?

Any assistance offered will be appreciated.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
It is very easy to check the actrive workbook name : like this:
VBA Code:
Dim sts As String
sts = ActiveWorkbook.Name
If Left(sts, 6) = "12 Dec" Then
 MsgBox (sts)
Else
 ActiveWorkbook.Close
End If
 
Upvote 0
Solution

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

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