If you look in John 7:24, it reads, "Do not judge by appearance, but judge with right judgement." What? What is this? A verse in the Bible telling use to judge?! It can't be!! But yes, it can. This verse is telling us to judge people not based on their looks, but based on the inside. Now, there's a difference between judging and making judgements. This is talking about making a judgement so that you don't hang around the wrong people. And the Bible does teach about that in Matthew 13 when Jesus tells the parable about the seeds. We don't want to get choked out by bad influences.
It's example time. Say a group of your friends want you to go to a party where there may or may not (but definitely will) be drinking involved. Now, right then you have to make a judgement. Going to that party is, as you know, a sin. Are you saying that those people are definitely not going to heaven? No. That is making a judgement. Also, if you decide that hanging out with those people is probably not the best idea because they are constantly tempting you to do something wrong, is that judging, or judgement? That is making a judgement. That is what John 7:24 is talking about. It doesn't matter how popular, good looking, rich, or funny they are. If they are a bad influence, then they shouldn't be huge parts of your life. Now, completely shunning them because of their choices isn't very Christian like, and does fall under the judging category. There does have to have an even balance, but that doesn't mean that you shouldn't make judgements on what you know is right or wrong.
I'm going to use another example, but this time it'll be a less common, more extreme case that doesn't really have to do with any biblical principals, but still applies. Say you were a murder suspect, (like I said, very extreme and I doubt this would happen to you) and you were being chased by a bunch of cops. You're running as fast as you can, and all of a sudden there's a fork in the road. You look at each road briefly, and see that one has a bunch of cop cars at the end, and the other has a nice little hiding place where you could sneak in undetected. Which way are you going to go? I don't know about you, but I'd go to the second road with the nice little hiding spot. What made you choose the second road? Probably not wanting to get caught by the police, right?! That's what happens when we make judgements. We don't want to get caught up in sin, so we HAVE to make judgements so we don't end up doing the wrong thing. And this isn't just with people, either. We have to do this with every decision we make.
So, just because someone tells you that you're judging them for doing something wrong, just remember that as long as you're judging righteously, you're still following God's word.