How to filter and copy a named range?

Lanterfant

I'm trying to export a filtered named range to a new workbook. My named range contains a variable amount of rows with a '0' in a specific column. I'd like to exclude those rows (which contain a '0' in column 'F') from my selection before exporting them to the new workbook.

Below is the code I'm using to copy the named range and paste it into a new workbook. So far so good, but I've got no clue on how to exclude the rows with a '0' in column 'F'; currently, the whole named range is pasted into a new workbook.

Dim MyFileName As String
Dim CurrentWB As Workbook, TempWB As Workbook

Set CurrentWB = ActiveWorkbook
ActiveWorkbook.ActiveSheet.Range("my named range").Copy


Set TempWB = Application.Workbooks.Add(1)
With TempWB.Sheets(1).Range("A1")
    .PasteSpecial xlPasteValues
    .PasteSpecial xlPasteFormats
End With
Darrell H

Assuming you have already filtered your data and the zeros are hidden, change the following line:

ActiveWorkbook.ActiveSheet.Range("my named range").SpecialCells(xlCellTypeVisible).Copy

If you have not filtered, then use AutoFilter

ActiveWorkbook.ActiveSheet.Range("my named range").AutoFilter Field:=(number of field), Criteria1:="<>0"

followed by the line above...

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

How do I copy the active file and name it using a value in a Named range - Goolgle script

from within word, copy and paste as picture a named excel range

Excel Vba Filter Range By Each Unique Value and Copy Data

Filter Range Copy Paste the Value and Create new Sheets

How to log where the copy has saved into a range

Check if Named Range is equal to another Named Range

How do I filter a range of numbers in R?

How to make date range filter in Django?

Named Range String limitations

R: How do I filter a named list on names present in a vector?

Excel VBA - How to check if target is a named range. If yes, paste range

How do I expand a range within a dateframe and copy the values?

Reference Specific Row in Named Range within another Named Range

Excel - Unicode named cell range

Adding Named Range reference in VBA

Dynamic Named Range - Disparate Cells

How to SUM all values of a Filter with a relative end range

Google sheet - how to filter the data with custom date range

How to filter json data with data range (React JS)

vba: copy sheet with named destination

Macro to copy paste range

LibreOffice: Advanced Filter with Named Ranges

How to remove directory named 'Module - Copy20102018' with spaces from GIT repository

Using query, Import Range and named range to either label the named range or ignore the header

VBA excel macro for a button that selects named reference from a named range

Copy the range of cells with Ctrl+A

Copy Excel range as Picture to Outlook

Copy only selected range of the row

Programmatically build a hyperlink to a named range in Sheets

TOP lista

  1. 1

    R Shiny: use HTML em funções (como textInput, checkboxGroupInput)

  2. 2

    O Chromium e o Firefox exibem as cores de maneira diferente e não sei qual deles está fazendo certo

  3. 3

    Como assinar digitalmente um documento PDF com assinatura e texto visíveis usando Java

  4. 4

    R Folheto. Dados de pontos de grupo em células para resumir muitos pontos de dados

  5. 5

    Gerenciar recurso shake de Windows Aero com barra de título personalizado

  6. 6

    Como obter dados API adequados para o aplicativo angular?

  7. 7

    UITextView não está exibindo texto longo

  8. 8

    Por que meus intervalos de confiança de 95% da minha regressão multivariada estão sendo plotados como uma linha de loess?

  9. 9

    Acessando relatório de campanhas na AdMob usando a API do Adsense

  10. 10

    Usando o plug-in Platform.js do Google

  11. 11

    Como posso modificar esse algoritmo de linha de visada para aceitar raios que passam pelos cantos?

  12. 12

    Dependência circular de diálogo personalizado

  13. 13

    Coloque uma caixa de texto HTML em uma imagem em uma posição fixa para site para desktop e celular

  14. 14

    iOS: como adicionar sombra projetada e sombra de traço no UIView?

  15. 15

    Como usar a caixa de diálogo de seleção de nomes com VBA para enviar e-mail para mais de um destinatário?

  16. 16

    Tabela CSS: barra de rolagem para a primeira coluna e largura automática para a coluna restante

  17. 17

    How to create dynamic navigation menu select from database using Codeigniter?

  18. 18

    Converter valores de linha SQL em colunas

  19. 19

    ChartJS, várias linhas no rótulo do gráfico de barras

  20. 20

    用@StyleableRes注释的getStyledAttributes。禁止警告

  21. 21

    não é possível adicionar dependência para com.google.android.gms.tasks.OnSuccessListener

quentelabel

Arquivo