Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

.: Vitrine

Carregando artigos...

Views

Mostrando postagens com marcador copy. Mostrar todas as postagens
Mostrando postagens com marcador copy. Mostrar todas as postagens

SANDWICH PROJECT 2016 - VBA Excel - Copy a Master Worksheet

SANDWICH PROJECT 2016 - VBA Excel - Copy a Master Worksheet



Sabe quando cria uma planilha mestra e gostaria de copiá-la rapidamente como um modelo para uma nova planilha?

Este código funciona muito bem com um calendárioplanilhas de dataentry (entrada de dados) mensais, e outras aplicações onde tem planilhas com praticamente o mesmo layout.

Estou supondo que a planilha que deseja copiar seja chamada de Master, e que esteja oculta quando executar a macro. 

Abra sua pasta de trabalho. Pressione Alt + F11 para visualizar o Editor do VBA. Clique duas vezes em ThisWorkbook. E cole o seguinte código na janela de código:

Dim NewPageName As String
Sub NewPage()
       Let Sheets("Master").Visible = True
       Sheets("Master").Copy After:=Worksheets(Worksheets.Count)
       Let NewPageName = InputBox("What would you like to call your new Worksheet")
       Let ActiveWindow.ActiveSheet.Name = NewPageName
       Let Sheets("Master").Visible = False
End Sub








SANDWICH PROJECT 2016 - VBA Access: Copiando query com outro nome programaticamente

SANDWICH PROJECT 2016 - VBA Access: Copiando query com outro nome programaticamente





















Não raro ocorre a necessidade de copiarmos o conteúdo de uma query existente para outra com um nome diferente. Quando esta necessidade surgir, não precisará perder tempo em saber como fazê-lo, abaixo está o caminho.

Dica: Uma forma similar pode ser utilizada para copiar quaisquer objeto do MS Access.

 Aprenda: 17 Passos Essenciais para Melhorar seu Código VBA 

Function CpyNQry (nQryNm As String, nQryNm As String) As Boolean
' André Bernardes 04/2009 bernardess@gmail.com 
' Copia uma query qualquer para outra com outro nome. 
CurrentDb().CreateQueryDef nQryNm, CurrentDb().QueryDefs(QryNm).SQL 
Let CpyNQry = (Len(CurrentDb().QueryDefs(nQryNm).Name) > 0) 
Application.RefreshDatabaseWindow
End Function


VBA Excel - Exemplos de Copiar e Colar - 05

Este código colará o intervalo do MS Excel num documento do MS Word, deixando-o interligado ao MS Excel.



Sub LinkWorkBookToMsWord()
    Dim xlTable As Object
    Dim r As Range
   

    Set r = Worksheets("Sheet1").Range("A1", Range("B65536").End(xlUp))

    Set xlTable = CreateObject("Word.Application")

    Let xlTable.Visible = True
    r.Copy
    xlTable.documents.Add
    xlTable.Selection.PasteSpecial Link:=True, DataType:=wdPasteOLEObject, Placement:= _
                                   wdInLine, DisplayAsIcon:=False
    xlTable.activedocument.SaveAs ThisWorkbook.Path & "/" & "LinkedToWord.doc"
    xlTable.documents.Close
    xlTable.Quit
    Application.CutCopyMode = False
End Sub

Tags: Excel, VBA, copy, paste, MS Word, Word,


Inline image 1

VBA Excel - Exemplos de Copiar e Colar - 04


Copie o intervalo especificado na Sheet1 e em seguida, cole-o na primeira linha vazia após a última entrada na coluna A da Plan2:


Sub CopyRangeToNextSheet()
Worksheets("Sheet1").Range("A5:D5").Copy Destination:=Worksheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
End Sub





Tags: Excel, VBA, copy, paste, 


Inline image 1

VBA Excel - Exemplos de Copiar e Colar - 03


Copie a última linha utilizada na coluna A Sheet1. E em seguida, cole na primeira linha vazia após a última entrada da coluna "A" Plan2.



Sub CopyRowPasteToNextSheet()


Worksheets("Sheet1").Range("A65536").End(xlUp).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)

    
End Sub


Tags: Excel, VBA, copy, paste, 


Inline image 1

VBA Excel - Exemplos de Copiar e Colar - 02

Esse aqui vai copiar o conteúdo da célula  C1 para a última célula usada na coluna "C" na Sheet1. Em seguida colará na primeira linha após a última entrada da coluna A na Plan2:



 Sub CopyPasteToOtherSheet()


Worksheets("Sheet1").Range(Range("C1"), Range("C65536").End(xlUp)).Copy Destination:=Worksheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)



End Sub



Tags: Excel, VBA, copy, paste, 


Inline image 1

VBA Excel - Exemplos de Copiar e Colar - 01

Este código copiará todo o conteúdo da coluna C e o colará na primeira célula em branco após a última entrada na coluna A


Sub CopyAndPaste()
    Range(Range("C1"), Range("C65536").End(xlUp)).copy Destination:=Range("A65536").End(xlUp).Offset(1, 0)


End Sub


Tags: Excel, VBA, copy, paste, 


Inline image 1

VBA Excel - Limpando Filtros - Clearing Filters

Sub ClearFilterListOrTable()
    Dim ACell As Range
    Dim ActiveCellInTable As Boolean

    'Check to see if the worksheet is protected.
    If ActiveSheet.ProtectContents = True Then
        MsgBox "This macro will not work when the worksheet is write-protected.", _
               vbOKOnly, "Clear filter example"
        Exit Sub
    End If

    'Set a reference to the ActiveCell named ACell. You can always use
    'ACell now to point to this cell, no matter where you are in the workbook.
    Set ACell = ActiveCell

    'Test to see if ACell is in a table or list. Note that by using ACell.ListObject, you
    'don't need to know the name of the table to work with it.
    On Error Resume Next
    ActiveCellInTable = (ACell.ListObject.Name <> "")
    On Error GoTo 0

    'If the cell is in a list or table, run the code.
    If ActiveCellInTable = True Then
        'Show all data in the table or list.
        On Error Resume Next
        ActiveSheet.ShowAllData
        On Error GoTo 0
    Else
        MsgBox "Select a cell in your list or table before you run the macro.", _
               vbOKOnly, "Clear filter example"
    End If
End Sub




brazilsalesforceeffectiveness@gmail.com

✔ Brazil SFE®Author´s Profile  Google+   Author´s Professional Profile   Pinterest   Author´s Tweets

VBA Excel - Filtrando Tabelas ou Listas - Filtering Tables or Lists


Calendário Compacto para 2014


O código a seguir filtra uma tabela ou lista. Para testá-lo usamos uma tabela semelhante à abaixo.


Basta digitar os dados e, em seguida, usar o procedimento descrito.

Sub FilterListOrTableData()
    Dim ACell As Range
    Dim ActiveCellInTable As Boolean
    Dim FilterCriteria As String

    'Check to see if the worksheet is protected.
    If ActiveSheet.ProtectContents = True Then
        MsgBox "This macro will not work when the worksheet is write-protected.", _
               vbOKOnly, "Filter example"
        Exit Sub
    End If

    'Set a reference to the ActiveCell named ACell. You can always use
    'ACell now to point to this cell, no matter where you are in the workbook.
    Set ACell = ActiveCell

    'Test to see if ACell is in a table or list. Note that by using ACell.ListObject, you
    'don't need to know the name of the table to work with it.
    On Error Resume Next
    ActiveCellInTable = (ACell.ListObject.Name <> "")
    On Error GoTo 0

    'If the cell is in a list or table, run the code.
    If ActiveCellInTable = True Then
        'Show all data in the table or list.
        On Error Resume Next
        ActiveSheet.ShowAllData
        On Error GoTo 0

        'This example filters on the first column in the List/Table
        '(change the field if needed). In this case the Table starts
        'in A so Field:=1 is column A, field 2 = column B, ......
        'Use "<>" & filtercriteria if you want to exclude the criteria from the filter.
        FilterCriteria = InputBox("What text do you want to filter on?", _
                                  "Type in the filter item.")
        ACell.ListObject.Range.AutoFilter _
                Field:=1, _
                Criteria1:="=" & FilterCriteria
    Else
        MsgBox "Select a cell in your list or table before you run the macro.", _
               vbOKOnly, "Filter example"
    End If
End Sub




Tags: Excel, VBA, cell, activecell, table, list, Copying, copy, Table, List, Worksheet, Workbook, filter




Inline image 1

diHITT - Notícias