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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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