How to copy data from one worksheet to another automatically and quickly using advanced filter with VBA.
Here's the complete VBA code:
Option Explicit
Sub copyData()
Dim rngData As Range, rngCriteria As Range
Set rngData = ThisWorkbook.Worksheets("data").Range("A1").CurrentRegion
Set rngCriteria = ThisWorkbook.Worksheets("data").Range("G1").CurrentRegion
Dim mymonthnum As Integer
mymonthnum = Mid(Range("G2"), 3, 2)
MsgBox mymonthnum
Dim mymonthname As String
mymonthname = MonthName(mymonthnum)
MsgBox mymonthname
ThisWorkbook.Worksheets(mymonthname).Cells.ClearContents
Dim rngOutput As Range
Set rngOutput = ThisWorkbook.Worksheets(mymonthname).Range("A1")
rngData.AdvancedFilter xlFilterCopy, rngCriteria, copytorange:=rngOutput, Unique:=False
ThisWorkbook.Worksheets(mymonthname).Columns.AutoFit
End Sub
Copy Data Using Advanced Filter with VBA
Теги
copy data using advanced filter with vbacopy data automatically using advanced filter with vbacopy data from one worksheet to another using advanced filter with vbaexcel vba tutorialexcel vba for beginnersexcel vba for advanced learnersexcel vba helpexcel vba easyexcel vba youtubeadvanced excel vbalearn advanced excel vbaexcel to vbaexcel vba beginner tutorialexcel vba tutorials for beginnersexcel vba advanced tutorialwhat is vba in excel