How to use Macro in a worksheet with filters? To move items

LuizRenanFB

New Member
Joined
Jun 13, 2022
Messages
1
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
  2. Mobile
Hi!

I would like some help,
I'm trying to create a spreadsheet for moving items using macro in a table that has filters.

I'm trying to use the macro to move products, "FROM" the initial position that the object is in (Cell C3), to "FOR" the final position that the object will be (Cell C5).

I had written a code but the line in the cell where the macro was recorded remains fixed, and not in the position/line that the filter selects resumes.

How can I solve this problem? Or is there a finer solution to accomplish this process?

______

Sub TESTMOVE()
'
' Macro1 Macro
'

'
Range("C3").Select
Selection.Copy
ActiveSheet.ListObjects("Tabela423").Range.AutoFilter Field:=5, Criteria1:=Range("C3").Value
Range("H11:K11").Select
Application.CutCopyMode = False
Selection.Copy
Range("H4").Select
ActiveSheet.Paste
Range("H11:K11").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("C5").Select
Selection.Copy
ActiveSheet.ListObjects("Tabela423").Range.AutoFilter Field:=5, Criteria1:=Range("C5").Value
Range("H4:K4").Select
Application.CutCopyMode = False
Selection.Copy
Range("H12").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.ListObjects("Tabela423").Range.AutoFilter Field:=5
End Sub
 

Attachments

  • tab.jpeg
    tab.jpeg
    55.9 KB · Views: 22

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,224,737
Messages
6,180,656
Members
452,992
Latest member
TokugawaIesuma

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