Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Need VBA file for automatic selection of sorted data


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



Hi Sagar and welcome to the Forum.

Firstly, we can't see your picture in your Question (only Excel files can be uploaded via the Add Files... button if you edit your question).

Secondly, this is a Q&A forum but we don't generally work with questions like "I need some code to do this..." (though you might get lucky!). Suggest you go the the Tutorials section (see link above) and look in the VBA section, attempt to solve your problem then come back when you get stuck and need some specific help.
John_Ru (rep: 5722) Nov 23, '22 at 10:56 am
Hello sagar2295 and welcome to the forum.

To be able to provide a possible solution more information is required.
Firstly, images cannot be uploaded - only Excel files;so if you could upload a sample Excel file that would be helpful.
After you sort your data you say you want to copy columns 1, 3, & 5 - do you mean columns A, C, & E? Do you want to copy all of the data in those columns or just a portion of it? Where do you intend to paste it? To a different worksheet in the same workbook or to a different workbook? When you paste the data do you want to overwrite the existing data or add this new data to the existing?
WillieD24 (rep: 382) Nov 23, '22 at 11:09 am
Hi Willie. I already asked for an Excel file but if you want to tackle writing code for Sagar (and you get a reply), I'll leave it to you 
John_Ru (rep: 5722) Nov 23, '22 at 11:31 am
Hi John,

When I began typing my post I did not see yours. Looking at the time stamps yours and mine are only 13 minutes apart. I also agree with your comments - we are here to help after they have tried on their own, not do do their work for them.
WillieD24 (rep: 382) Nov 24, '22 at 1:04 pm
No problem Willie, that kind of thing happens. From the lack of response so far, it looks like this may be a user who posts the same question on several forums, possibly not acknowledging the help they get :( Let's see. 
John_Ru (rep: 5722) Nov 24, '22 at 1:24 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login