Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/06/2005, 11:00
Ercikson Alvare
 
Fecha de Ingreso: junio-2005
Mensajes: 5
Antigüedad: 19 años
Puntos: 0
Corrijo, ya que el codigo anterior tenía un problemita.
Sub Bajas()
Dim msExcelApp As New Excel.Application
Dim msExcelWorkbook As New Excel.Workbook
Dim msExcelWorksheet As New Excel.Worksheet
Dim FileName as string
Dim Leer as boolean
Dim Codigo as string
Dim Row as long
Dim Col as long

FileName="c:\ejemplo.xls"

Set msExcelApp = GetObject("", "excel.application")
'Esto es para indicar si quieres que excell se vea
msExcelApp.Visible = True '
msExcelApp.Workbooks.Open FileName

msExcelApp.Sheets("Bajas").Select

leer=true
Row=1
Col=1
'Asumiendo que el codigo esta en la columna 1 en excell
do while leer
codigo=msExcelApp.Cells(Row, Col).value
if codigo<>"" then
deleteRow codigo,msExcelApp
else
leer=false
end if
loop
msExcelApp.Workbooks.Application.ActiveWorkbook.Cl ose False
msExcelApp.Quit
Set msExcelApp = Nothing

end Sub


Sub DeleteRow(Cod as string,ByRef PWorkbook As Excel.Application)
Dim CodActual as string
Dim Row as long
Dim Col as string
Dim RedEx as boolean

Row=1
Col=1
Do while RedEx
Codactual=msExcelApp.Cells(Row, Col).value
if codactual=Cod then
msExcelApp.Cells(Row, Col).select
PWorkbook.Sheets("Bajas").Selection.Delete Shift:=xlUp
ReadEx=false
end if
row=row+1
loop

end sub