Dias inabiles-1 -2 -3

12/10/2004 - 16:54 por osalazarg | Informe spam
Buenos dia alguien me podria ayudar por favor, tengo que abrir varios
archivos de texto considerando los dias habiles de lunes a viernes y los
dias inabiles sabado y domingo, con este formato los archivos
"AAAAMMDD"_13240.TXT

20040930_13240.txt
20041001_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 Luis
13/10/2004 - 02:08 | Informe spam
Sago, cuando abres los archivos, que haces con los datos? Sería bueno que me
enviaras esta informacion para poder ayudarte


Luis Medina
MENUFazt - Menu Excel Multifunciones
http://www11.brinkster.com/luism0/


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

20040930_13240.txt
20041001_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.769 / Virus Database: 516 - Release Date: 24/09/2004

Preguntas similares