Im here again with another problem and ill probably post again later. Im not putting everthing I want in a single topic because I want to learn how do it instead of getting something done by someone else.
My Problem:
I want to copy just some columns (C, S, U) of my sheet after I filtered it.
One of the problems is that I want to do it for multiple filter criterias so I just cant say, for exemple A1:A500, because I dont know how many entrys one filter has
The second problem is copying the columns and pasting it in another sheet
Here is my code. it will filter by the criterias i want, but i didnt put the loop for all the sheets yet, but its not the problem. I'm stuck at the part that copy the columns
Function IsWorkBookOpen(FileName As String)
Dim FF As Integer, ErrNum As Integer
Select Case ErrNum
Case 0: IsWorkBookOpen = False
Case 70: IsWorkBookOpen = True
Case Else: Error ErrNum
End Select
End Function
Sub extrair()
Dim Font As Workbook
Dim Dest As Workbook
Dim info
info = IsWorkBookOpen("C:\Users\EU\Desktop\Projetos\Arquivos fonte\Mestre de Pedidos.xlsx")
If info = False Then
Workbooks.Open ("C:\Users\EU\Desktop\Projetos\Arquivos fonte\Mestre de Pedidos.xlsx")
End If
Set Font = Workbooks("Mestre de Pedidos.xlsx")
Set Dest = Workbooks("Dados.xlsm")
mesNome = Left(Dest.Worksheets(1).Name, 3)
Ano = Right(Dest.Worksheets(1).Name, 2)
mes = Month(DateValue("01-" & mesNome & "-1900"))
bInicio = mes & "/01/20" & Ano
bFim = mes & "/31/20" & Ano
With Font.Worksheets(1)
.AutoFilterMode = False
With .Range("A1:V1")
.AutoFilter
.AutoFilter Field:=10, Criteria1:="Entregue"
.AutoFilter Field:=19, Criteria1:=">=" & bInicio, Operator:=xlAnd, Criteria2:="<=" & bFim
End With
End With
End Sub
Display More
I did find some answers for this problem in this forum but they were too complex for me to undestand and modify for my use or it used this syntax Range("A1:A600") but when I run it it gives me error 438
---------------------------------------
Update:
I found a way to do it here is it if anyone is interested
lRow = Font.Worksheets(1).Range("C" & Font.Worksheets(1).Rows.Count).End(xlUp).Row
Font.Worksheets(1).Range("C1:C" & lRow).Copy Dest.Worksheets(Z).Range("A1")
Font.Worksheets(1).Range("K1:K" & lRow).Copy Dest.Worksheets(Z).Range("B1")
Font.Worksheets(1).Range("U1:U" & lRow).Copy Dest.Worksheets(Z).Range("C1")
Font.Worksheets(1).Range("S1:S" & lRow).Copy Dest.Worksheets(Z).Range("D1")