excel


How to exclude weekends while opening file in VBA?


everyday one file will create with date as previous working day.
Example, (05/16/2017, Tuesday) file will create with date as 05/15/2017, Monday.
whereas on 05/15/2017, Monday file will create with date as 05/12/2017.
I am trying to open file using VBA with the below code,
file name Format="C:\users\Duke\report'05/15/2017'.XLS"
sub OpenFile()
Const fpath As String = "C:\users\Duke\Report"
Dim fname As String
fname = Format(Date - (Weekday((Date),Vbmonday) - 1), "yyyy-mm-dd")
fname = "'" & fname & "'" & ".XLS"
Dim path As String
path = fpath & fname
end ()
But it is not working, Please suggest.
VBA does not have a built in method to handle workdays. But the following might compute the desired date, if your code only runs M-F and SS are weekends:
Dim X As Long
X = IIf(Weekday(Date) = vbMonday, 3, 1)
fname = Format(Date - X, "yyyy-mm-dd")
If your code might also run on the weekends, then you will have to define what you want to happen, in that event

Related Links

How to update a specific row of a table in Excel using Microsoft Graph?
columns' values based on specific rows in pivot table excel
VBA Adding cells from one sheet to another by cell
Searchng a sheet for a value and returning row & column numbers
How to take a control of specific cell of XL?
Vlookup exact text on a cell text string
HTTP GET responds with empty body, downloads excel document in IE
VBA replace comma with line break in word?
Excel online sharing
Change cell value based off of selection from ListBox
How to remove hidden quotes
Sorting out data by insert and copy and paste special
Excel VB to create monthly table based on user input
Week number from Date format in excel(Monthwise_Week Number)
Is there a way to connect to an external powerpivot data model from an Excel workbook?
VBA for Sending Outlook Mail from Excel automatically even when workbook is closed [on hold]

Categories

HOME
react-native
qt5
.net-core
amazon-dynamodb
automation
veins
statistics
conditional
import
post
visual-studio-mac
linuxmint
cordova-plugins
protege
directive
geometry
category
serenity-bdd
ajaxform
intercept
google-nativeclient
fork
boost-python
formsets
ddos
bus
maxlength
tensorflow-serving
easymock
fixtures
lektor
bootstrapping
fitnesse-slim
digestive-functors
webos
gulp-usemin
ffi
zlib
dwt
react-d3
gear-vr
graylog
prime-factoring
google-api-v3
spring-java-config
jake
local-variables
azure-webjobssdk
imshow
archiving
testdroid
orchardcms-1.9
gethostbyname
kdiff3
jquery-widgets
splash-screen
traceroute
rgraph
network-monitoring
angular-component-router
ooyala
velocity.js
payara
argo
sqlsrv
objdump
avm2
fileapi
excel-2008
fluid-layout
sql-agent-job
kermit
savefiledialog
certificatestore
reagent
allocation
srv
componentkit
string-search
sharepoint-clientobject
string-conversion
kendo-validator
freetextbox
worklight-studio
zebra-puzzle
mapstraction
harfbuzz
node-http-proxy
hierarchyid
rdata
dynamic-language-runtime
iwebkit
ejbql
twisted.internet
umbraco5
single-user
fql.multiquery
trx
widechar
live-cd
abbreviation

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile