Dias habiles -1 -2 -3

19/10/2004 - 17:05 por osalazarg | Informe spam
Buenos dia alguien me podria ayudar por favor,vuelvo a poner esta consulta.
tengo que abrir varios archivos de texto considerando los dias habiles de
lunes a viernes y los
dias inhabiles sabado y domingo, con este formato los archivos
"AAAAMMDD"_13240.TXT

20041008_13240.txt
20041011_13240.txt
20041012_13240.txt
20041013_13240.txt
20041014_13240.txt
20041015_13240.txt

El primer archivo que necesito abrir es el dia anterior habil, ejemplos:

cuando es lunes necesito abrir el archivo del viernes
cuando es martes y necesito abrir el del lunes.
miercoles necesito abrir el del martes
jueves necesito abrir el del miercoles. y asi.

El segundo archivo que necesito abrir dos dias anteriores habiles ,
ejemplos:

cuando es lunes necesito abrir el del jueves.
martes y necesito abrir el del viernes.
miercoles necesito abrir el del lunes
jueves necesito abrir el del martes. y asi...

El tercer archivo que necesito abrir tres dias anteriores habiles ,
ejemplos:

cuando es lunes necesito abrir el del miercoles.
martes y necesito abrir el del jueves.
miercoles necesito abrir el del viernes
jueves necesito abrir el del lunes. y asi.

hice esta macro pero no me funciono, ya no la acabe espero que alguien me
podria ayudar por favor.

Private Function BuscarSigDiaHabil(ByVal Fecha As Date) As String
Dim DiaDeHoy As String
DiaDeHoy = StrConv(Format(Fecha, "ddd"), vbLowerCase)
Select Case DiaDeHoy
Case "lun", "mond": BuscarSigDiaHabil = Format(Fecha - 3, "yyyymmdd")
Case "sáb", "sab", "sat": BuscarSigDiaHabil = Format(Fecha - 1,
"yyyymmdd")
Case "dom", "sun": BuscarSigDiaHabil = Format(Fecha - 2, "yyyymmdd")
Case Else: BuscarSigDiaHabil = Format(Fecha - 1, "yyyymmdd")

End Select
End Function
Private Function BuscarAntDiaHabil(ByVal Fecha As Date) As String
Dim DiaDeHoy As String
DiaDeHoy = StrConv(Format(Fecha, "ddd"), vbLowerCase)
Select Case DiaDeHoy
Case "mar", "tue": BuscarAntDiaHabil = Format(Fecha - 4, "yyyymmdd")

End Select
End Function



Sub checar_comisiones()

Application.ScreenUpdating = False
Dim strArchivo As String
strArchivo = BuscarSigDiaHabil(Date)
strArchivo1 = BuscarAntDiaHabil(Date)
ChDir "C:\EDOCTA"
Workbooks.OpenText Filename:="C:\EDOCTA\" & strArchivo & "_13240" &
".TXT", Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(31, 1), Array(50, 1), Array(79, 1), Array(95, 1),
Array(100, 1), Array(117, 2))
Application.DisplayAlerts = False
Sheets(strArchivo & "_13240").Name = "ESTADO DE CTA"
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\ESTADO DE CTA.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.DisplayAlerts = True


ChDir "C:\EDOCTA"
Workbooks.OpenText Filename:="C:\EDOCTA\" & strArchivo1 & "_13240" &
".TXT", Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(31, 1), Array(50, 1), Array(79, 1), Array(95, 1),
Array(100, 1), Array(117, 2))
Application.DisplayAlerts = False
Sheets(strArchivo1 & "_13240").Name = "ESTADO DE CTA DIA ANTERIOR"
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\ESTADO DE CTA DIA ANTERIOR.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.DisplayAlerts = True
End Sub


Saludos.
 

Leer las respuestas

#1 L. A. M.
20/10/2004 - 15:16 | Informe spam
Te coloque una solucion dias antes pero parece que no la revisaste.



Luis Medina
Menufazt - Utilidades y juegos en Excel
http://www11.brinkster.com/LUISM0/

"sago" escribió en el mensaje
news:
Buenos dia alguien me podria ayudar por favor,vuelvo a poner esta
consulta.
tengo que abrir varios archivos de texto considerando los dias habiles de
lunes a viernes y los
dias inhabiles sabado y domingo, con este formato los archivos
"AAAAMMDD"_13240.TXT

20041008_13240.txt
20041011_13240.txt
20041012_13240.txt
20041013_13240.txt
20041014_13240.txt
20041015_13240.txt

El primer archivo que necesito abrir es el dia anterior habil, ejemplos:

cuando es lunes necesito abrir el archivo del viernes
cuando es martes y necesito abrir el del lunes.
miercoles necesito abrir el del martes
jueves necesito abrir el del miercoles. y asi.

El segundo archivo que necesito abrir dos dias anteriores habiles ,
ejemplos:

cuando es lunes necesito abrir el del jueves.
martes y necesito abrir el del viernes.
miercoles necesito abrir el del lunes
jueves necesito abrir el del martes. y asi...

El tercer archivo que necesito abrir tres dias anteriores habiles ,
ejemplos:

cuando es lunes necesito abrir el del miercoles.
martes y necesito abrir el del jueves.
miercoles necesito abrir el del viernes
jueves necesito abrir el del lunes. y asi.

hice esta macro pero no me funciono, ya no la acabe espero que alguien me
podria ayudar por favor.

Private Function BuscarSigDiaHabil(ByVal Fecha As Date) As String
Dim DiaDeHoy As String
DiaDeHoy = StrConv(Format(Fecha, "ddd"), vbLowerCase)
Select Case DiaDeHoy
Case "lun", "mond": BuscarSigDiaHabil = Format(Fecha - 3, "yyyymmdd")
Case "sáb", "sab", "sat": BuscarSigDiaHabil = Format(Fecha - 1,
"yyyymmdd")
Case "dom", "sun": BuscarSigDiaHabil = Format(Fecha - 2, "yyyymmdd")
Case Else: BuscarSigDiaHabil = Format(Fecha - 1, "yyyymmdd")

End Select
End Function
Private Function BuscarAntDiaHabil(ByVal Fecha As Date) As String
Dim DiaDeHoy As String
DiaDeHoy = StrConv(Format(Fecha, "ddd"), vbLowerCase)
Select Case DiaDeHoy
Case "mar", "tue": BuscarAntDiaHabil = Format(Fecha - 4, "yyyymmdd")

End Select
End Function



Sub checar_comisiones()

Application.ScreenUpdating = False
Dim strArchivo As String
strArchivo = BuscarSigDiaHabil(Date)
strArchivo1 = BuscarAntDiaHabil(Date)
ChDir "C:\EDOCTA"
Workbooks.OpenText Filename:="C:\EDOCTA\" & strArchivo & "_13240" &
".TXT", Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(31, 1), Array(50, 1), Array(79, 1), Array(95, 1),
Array(100, 1), Array(117, 2))
Application.DisplayAlerts = False
Sheets(strArchivo & "_13240").Name = "ESTADO DE CTA"
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\ESTADO DE CTA.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.DisplayAlerts = True


ChDir "C:\EDOCTA"
Workbooks.OpenText Filename:="C:\EDOCTA\" & strArchivo1 & "_13240" &
".TXT", Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(31, 1), Array(50, 1), Array(79, 1), Array(95, 1),
Array(100, 1), Array(117, 2))
Application.DisplayAlerts = False
Sheets(strArchivo1 & "_13240").Name = "ESTADO DE CTA DIA ANTERIOR"
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\ESTADO DE CTA DIA ANTERIOR.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.DisplayAlerts = True
End Sub


Saludos.







Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.775 / Virus Database: 522 - Release Date: 10/08/2004

Preguntas similares