Macro for automatic selection of sorted data

New Contributor
I would like to create a macro for automatic selection of the filtered data. Please help me with VBA code.
The steps for selecting the data:
1) I sorted raw data
2) From that filtered data, I am selecting only 3 columns (Column 1st, 3rd, 5th)
3) Selecting 3 columns for making a copy-paste
After performing any filtering/sorting, I need to select the data from the specific three columns.
Please see below pic, I need to select only orange
1.png2.png3.png4.png3 columns after soring the data
1 Reply

@sagar2295890 Do you need to select and delete columns? You could instead add a worksheet with formulas that filter the data to just the content you desire.

 

But if you really need to write VBA...  Is this assigned work for a class?  You can learn some of VBA by recording a macro...

  1. On the View ribbon, to the far right, you should see a Macros section. Click the "Record Macro..." item.
  2. In the dialog that appears, you can leave the "Macro name" at is default (Macro1 or Macro2 or...) or specify your own name (no spaces or special characters other than underscore). In the "Store macro in:" dropdown list, choose "This workbook". Click OK.
  3. Use whatever Excel features (in the user interface) -- selecting, copying, pasting, and/or deleting, etc. -- you require to make the desired results appear.
  4. Back on the View ribbon, click the "Macros | Stop Recording" item.

...and studying its content.

  1. Click the "Macros | View Macros" item.
  2. In the dialog that appears, select your macro, and click the Edit button.