VBA code for filtered data

Hello , 

 

I am new to VBA . I am trying to select filtered data from work sheet (Emp_id) and  paste it into worksheet All_emp. I am filtering data on R column left ( selecting ‘Y’ and Blank Data “” ) . While pasting data in sheet All_emp I am adding one more column status and updating all Y data with inactive and black data with active . The format of excel is same . while copying data i am selecting filtered displayed data without header and paste it below header in All_emp Sheet .

 

The code execute properly for this set of data . Please find attached sheet , however when there is any change of data then code is giving me an error . 

 

 

Kindly suggest how i can copy paste data irrespective of what data present in Emp_id sheet . 

 

Sub Macro4()

‘ Macro4 Macro

 

        ActiveSheet.Range(“$C$5:$R$45″).AutoFilter Field:=16, Criteria1:=”<>”

        Range(“C11:O37”).Select

        Selection.Copy

        Sheets(“All_emp”).Select

            Range(“A2”).Select

            ActiveSheet.Paste

            ActiveWindow.ScrollColumn = 2

            ActiveWindow.ScrollColumn = 3

            ActiveWindow.ScrollColumn = 4

            ActiveWindow.ScrollColumn = 5

            ActiveWindow.ScrollColumn = 6

                Range(“N1”).Select

                Application.CutCopyMode = False

                ActiveCell.FormulaR1C1 = “Status”

                Range(“N2”).Select

          ActiveCell.FormulaR1C1 = “INACTIVE”

               Range(“N2”).Select

                Selection.Copy

    Range(“N3:N6”).Select

    ActiveSheet.Paste

    Sheets(“Emp_id”).Select

    ActiveSheet.Range(“$C$5:$R$45″).AutoFilter Field:=16, Criteria1:=”=”

    Range(“C6:O45”).Select

    Application.CutCopyMode = False

    Selection.Copy

    Sheets(“All_emp”).Select

    ActiveWindow.ScrollColumn = 5

    ActiveWindow.ScrollColumn = 4

    ActiveWindow.ScrollColumn = 3

    ActiveWindow.ScrollColumn = 2

    ActiveWindow.ScrollColumn = 1

    Range(“A7”).Select

    ActiveSheet.Paste

    ActiveWindow.ScrollColumn = 2

    ActiveWindow.ScrollColumn = 3

    ActiveWindow.ScrollColumn = 4

    ActiveWindow.ScrollColumn = 5

    ActiveWindow.ScrollColumn = 6

    Range(“N7”).Select

    Application.CutCopyMode = False

    ActiveCell.FormulaR1C1 = “Active”

    Range(“N7”).Select

    Selection.Copy

    Range(“N8:N41”).Select

    ActiveSheet.Paste

    ActiveWindow.SmallScroll Down:=-36

    Sheets(“Emp_id”).Select

End Sub

 

By: Nik

1,843 thoughts on “VBA code for filtered data

  1. buy wedding silk sarees

    Mу brother reсommended I might like this blog.
    Ηe was totally right. This post actualⅼy made my day.
    Уou сan not imаgine simply how much time I had spent
    for this info! Thanks!

  2. harga-jual.com

    I really love your site.. Pleasant colors & theme. Did you create this website yourself? Please reply back as I’m looking to create my own blog and would like to know where you got this from or exactly what the theme is called. Cheers!

  3. http://143.95.144.116/

    Aw, this was an extremely good post. Finding the time and actual effort to generate a top notch article… but what can I say… I procrastinate a whole lot and never manage to get anything done.

  4. iamgutsclub.com

    Having read this I believed it was really enlightening. I appreciate you taking the time and effort to put this informative article together. I once again find myself spending way too much time both reading and posting comments. But so what, it was still worthwhile!

  5. vivo slot

    I have to thank you for the efforts you’ve put in penning this blog. I’m hoping to view the same high-grade blog posts by you in the future as well. In fact, your creative writing abilities has encouraged me to get my very own website now 😉

  6. 谷歌优化

    Hi there, You’ve done an excellent job. I will definitely
    digg it and personally suggest to my friends. I’m confident they’ll be benefited from this website.

  7. vivoslot.net

    An impressive share! I’ve just forwarded this onto a coworker who has been doing a little homework on this. And he in fact ordered me breakfast because I discovered it for him… lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanx for spending time to discuss this matter here on your blog.

  8. slot online

    An impressive share! I’ve just forwarded this onto a friend who has been doing a little homework on this. And he actually bought me dinner simply because I found it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending some time to discuss this topic here on your internet site.

  9. vivo slot

    I’d like to thank you for the efforts you’ve put in penning this blog. I’m hoping to see the same high-grade content by you in the future as well. In truth, your creative writing abilities has motivated me to get my own site now 😉

  10. apk vivoslot

    Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I’m going to return yet again since i have book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide others.

  11. link alternatif vivoslot

    I would like to thank you for the efforts you’ve put in writing this website. I am hoping to view the same high-grade content from you in the future as well. In truth, your creative writing abilities has encouraged me to get my own blog now 😉

  12. togel sydney

    Good web site you’ve got here.. It’s hard to find good quality writing like yours nowadays. I seriously appreciate people like you! Take care!!

  13. dingdong 36d

    You’re so interesting! I do not suppose I’ve truly read through something like that before. So nice to discover someone with a few original thoughts on this topic. Really.. thank you for starting this up. This website is one thing that is needed on the internet, someone with some originality!

  14. Situs Poker Online

    Wonderful goods from you, man. I’ve have in mind your stuff previous to and you are just too
    fantastic. I really like what you have received here, really like what you
    are saying and the best way through which you are saying it.
    You are making it entertaining and you still take care of to stay it wise.
    I can not wait to read much more from you. That is really a wonderful site.

  15. togel online

    I blog quite often and I genuinely thank you for your content. The article has really peaked my interest. I’m going to take a note of your site and keep checking for new information about once a week. I subscribed to your Feed as well.

  16. judi poker online

    An interesting discussion is worth comment. I think that you ought to write more on this issue, it may not be a taboo matter but usually folks don’t talk about these topics. To the next! Kind regards!!

  17. togel hk

    I blog frequently and I seriously appreciate your information. The article has truly peaked my interest. I will book mark your blog and keep checking for new information about once per week. I opted in for your RSS feed as well.

  18. qq online

    Greetings! Very helpful advice in this particular article! It’s the little changes that make the biggest changes. Thanks a lot for sharing!

  19. bandar qq

    The very next time I read a blog, I hope that it does not fail me as much as this one. I mean, Yes, it was my choice to read, however I genuinely believed you’d have something useful to talk about. All I hear is a bunch of complaining about something you could fix if you weren’t too busy seeking attention.

  20. judi poker online

    Howdy! I could have sworn I’ve been to this blog before but after going through a few of the articles I realized it’s new to me. Anyways, I’m certainly pleased I found it and I’ll be bookmarking it and checking back regularly!

  21. dominoqq

    May I just say what a comfort to uncover someone that actually knows what they are discussing online. You definitely realize how to bring a problem to light and make it important. More people really need to read this and understand this side of the story. It’s surprising you are not more popular given that you certainly have the gift.

  22. togel hk

    Right here is the right website for everyone who wants to understand this topic. You realize so much its almost tough to argue with you (not that I actually will need to…HaHa). You certainly put a fresh spin on a subject that has been written about for many years. Great stuff, just wonderful!

  23. bandarqq

    You’ve made some really good points there. I checked on the net for more info about the issue and found most individuals will go along with your views on this website.

  24. game slot online uang asli

    An impressive share! I have just forwarded this onto a coworker who had been conducting a little research on this. And he actually ordered me lunch due to the fact that I stumbled upon it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this subject here on your site.

Comments are closed.