VBA-Copy row from table based on date and paste it to another sheet

goob90

New Member
Joined
Nov 12, 2021
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hello!

I have a spreadsheet that lists employee insurance information. I am using a power query to update the table every month. I am wanting to create a code that loops through the ListObject and moves the row to a new sheet based on the effective date.

Example:

Effective date
10/01/2021-moves row to sheet "October"
02/01/2021-moves row sheet "February"

Can someone point me in the right direction? Thanks!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
1636740751827.png
 
Upvote 0
Hello,​
link your workbook on a files host website like Dropbox …​
 
Upvote 0
Hello,​
link your workbook on a files host website like Dropbox …​
 
Upvote 0

Is it your real workbook ? If yes so from which country 'Janurary' and 'Feburary' come from ?!​
 
Upvote 0
According to your attachment a VBA demonstration for starters :​
VBA Code:
Sub Demo1()
        Dim S&
        Application.ScreenUpdating = False
    With [Data!A1].CurrentRegion
        For S = 2 To 13
            Sheets(S).UsedRange.Clear
           .Range("K2").Formula = "=MONTH(A2)=" & S - 1
           .AdvancedFilter 2, .Range("K1:K2"), Sheets(S).[A1]
        Next
           .Range("K2").Clear
    End With
        Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
According to your attachment a VBA demonstration for starters :​
VBA Code:
Sub Demo1()
        Dim S&
        Application.ScreenUpdating = False
    With [Data!A1].CurrentRegion
        For S = 2 To 13
            Sheets(S).UsedRange.Clear
           .Range("K2").Formula = "=MONTH(A2)=" & S - 1
           .AdvancedFilter 2, .Range("K1:K2"), Sheets(S).[A1]
        Next
           .Range("K2").Clear
    End With
        Application.ScreenUpdating = True
End Sub
This works fantastically, thank you!
 
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,058
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top