USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Limpas dados do Excel
ATS
OURINHOS
SP - BRASIL
ENUNCIADA !
Postada em 16/05/2006 15:27 hs            
Como fazer para limpar todos os dados em uma planilha do Excel com excessão da primeira linha.
TÓPICO EDITADO
 
Geronimo
Pontos: 2843
JOINVILLE
SC - BRASIL
ENUNCIADA !
Postada em 16/05/2006 18:09 hs            
Estou presumindo que você tenha os codigos para acessar o excel .
Então para limpar :
Worksheets("Plan1").Range("a2:IV65000").ClearContents
 
Isto você pode colocar em comandbutton ou ao entrar na planilha:
Private Sub Workbook_Open()
Worksheets("Plan1").Range("a2:IV65000").ClearContents
End Sub

"O pior inimigo que você poderá encontrar será sempre você mesmo."
   
ATS
OURINHOS
SP - BRASIL
ENUNCIADA !
Postada em 17/05/2006 08:37 hs            
Olá não funcionou, estou enviando parte do codigo as vezes posso estar fazendo errado, obrigado.
 
Dim Plan As Object
If rsTabela.EOF = False And rsTabela.BOF = False Then
   'Verifica se o arquivo de modelo do Excel existe
   If Existe(App.Path & "TextoTabela_de_Produtos.xls") Then
      Set Plan = CreateObject("Excel.Application")
      Plan.Workbooks.Open App.Path & "TextoTabela_de_Produtos.xls"
      Plan.Worksheets("Plan1").Range("a2:IV65000").ClearContents
     
      With Plan
         .Range("A1").value = "Autor"
         .Range("B1").value = "Título"
         .Range("C1").value = "Editora"
         .Range("D1").value = "Ano"
         .Range("E1").value = "Estante"
         .Range("F1").value = "Preço"
         .Range("G1").value = "Descrição"
         .Range("H1").value = "Peso"
         .Range("I1").value = "Meta-prateleira"
         i = 2
         Do While rsTabela.EOF = False
            If rsTabela!PrecoVenda <> "0" And rsTabela!PrecoVenda <> "R$ 0,00" And rsTabela!PrecoVenda <> "0,00" And rsTabela!QuantidadeEstoque > 0 Then
               .Cells(i, 1) = rsTabela!Autor
               .Cells(i, 2) = rsTabela!DescricaoProduto
               .Cells(i, 3) = rsTabela!Editora
               .Cells(i, 4) = rsTabela!Ano
               .Cells(i, 5) = rsTabela!Assunto
               .Cells(i, 6) = rsTabela!PrecoVenda
               .Cells(i, 7) = rsTabela!Observacao
               .Cells(i, 8) = rsTabela!Peso
               .Cells(i, 9) = rsTabela!Setor
               .Cells(i, 10) = " "
               i = i + 1
               contador = contador + 1
            End If
            If rsTabela!PrecoVendaNovo <> "0" And rsTabela!PrecoVendaNovo <> "R$ 0,00" And rsTabela!PrecoVendaNovo <> "0,00" And rsTabela!QuantidadeEstoqueNovo > 0 Then
               .Cells(i, 1) = rsTabela!Autor
               .Cells(i, 2) = rsTabela!DescricaoProduto
               .Cells(i, 3) = rsTabela!Editora
               .Cells(i, 4) = rsTabela!Ano
               .Cells(i, 5) = rsTabela!Assunto
               .Cells(i, 6) = rsTabela!PrecoVendaNovo
               .Cells(i, 7) = rsTabela!Observacao
               .Cells(i, 8) = rsTabela!Peso
               .Cells(i, 9) = rsTabela!Setor
               .Cells(i, 10) = " "
               i = i + 1
               contador = contador + 1
            End If
            rsTabela.MoveNext
         Loop
      End With
      Plan.ActiveWorkbook.SaveAs FileName:="C:SGITextoTabela_de_Produtos.xls"
      Plan.ActiveWorkbook.Close SaveChanges:=False
      Plan.Quit
      Set Plan = Nothing
   Else
      Beep
      MsgBox "Arquivo modelo do Excel não foi localizado para que os registros " & vbCrLf & " sejam exportados, contate o administrador do sistema.", vbCritical, "Aviso"
      Exit Sub
   End If
   
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2025   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página