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

VBA - thisworkbook.path
VBA code running but not having effect
VBA-style range selection in Excel
Sorting Excel data
MS Office - ActiveX Buttons switching places
Not able to access excel file
Sending Excel VBA email
Excel VBA 'If Then Else' Statement fails
How to run sub procedure [closed]
How to compare data where data matches (or doesn't match) on two columns?
Left vlookup error
GAS - Script to duplicate a script
Convert Excel VBA Analysis ToolPack “Fourier” Sub into a UDF Function
Excel VBA look through sheets and copy column range to another sheet
VBA/macro to move rows to various other sheets automatically
Macro to color the row nos and copy colored rows to another sheet

Categories

HOME
momentjs
dll
openerp
amazon-dynamodb
solr6
iframe
jupyter-notebook
g2o
post
visual-studio-mac
etcd
facebook-live-api
cordova-plugins
chat
sage
terraform
autofixture
protege
bpm
delaunay
ninja
sapply
restcomm
m3u8
video-processing
libreoffice-base
shogun
prestashop-1.6
google-fusion-tables
accelerometer
intercept
ssrs-2016
structured-data
oracle-data-integrator
sandbox
u2
provider
angular-openlayers
protobuf-c
side-effects
lsmeans
gsutil
responsive-filemanager
uicollectionviewcell
r6
dreamhost
itunes-store
instrumentation
ios6
friend-function
virsh
erpnext
ikvm
wso2dss
knockout-validation
sift
c#-to-vb.net
synopsys-vcs
rollbar
voxel
date-formatting
aide-ide
jwrapper
reportviewer2008
google-plus-domains
ienumerable
reducers
listboxitem
eclipse-emf-ecore
avm2
adobe-dps
fileapi
github-linguist
typescript1.7
custom-validators
seeding
scrollviewer
mongojs
gliffy
syntactic-sugar
deface
mashup
factoring
topcoat
ubuntu-13.04
gideros
panning
maskedinput
icefaces-1.8
appmobi
jlayer
nexus-7
sts-securitytokenservice
plcrashreporter
glow
wcsf
mindmapping
silverlight-embedded
tomahawk
dft
dynamic-css
application-design
html-rendering
microsoft.build

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile