PDA

View Full Version : Hey coders got a (hopefully) easy one VBA



Assassin
04-18-2013, 03:22 PM
Sub moveyesdata()
'
' moveyesdata Macro
'
' Keyboard Shortcut: Ctrl+q
'

Columns("A:R").Select
Selection.AutoFilter
Range("C1").Select
ActiveSheet.Range("$A$1:$C$10000").AutoFilter Field:=1, Criteria1:="XX"
Range("A1:C1000").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
ActiveSheet.Next.Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
ActiveSheet.Previous.Select
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Range("A1").Select
MsgBox "Completed"
End Sub

How would I change this to add in that in Field 18 we need less than 100 (the number)?

Criteria1 is already filled just edited out for obvious reasons.

Locust
04-18-2013, 03:24 PM
ohgod i haven't done vb for years. I have too many projects to code to take a look at this right now :/.

Assassin
04-18-2013, 03:39 PM
I know it should be easy right? Stupid simplistic code :P

Locust
04-18-2013, 08:09 PM
i finished my project faster than i predicted tonight. If you could format exactly the way it looks I can take a look at it. Also, what are you trying to do with it?

Patmonster
04-18-2013, 09:07 PM
If you format it and/or add a screen shot I'll look into it as well. My laptop just crashed and I had to start from scratch soooo I won't be able to toy with it, but I have no problem giving suggestions.

Assassin
04-18-2013, 11:24 PM
Lol that's a VBA script for a macro in Excel. It finds something I specify and copies it from one sheet to the next (filtering :)) So I'm trying to add a way to make it filter another thing at the same time...say a word and a number. From field 18. Only problem is when I put Field:=18, criteria1:"XX" It breaks at Field:18. Idk why. I just need to filter two things out.

acolyte_to_jippity
04-18-2013, 11:27 PM
Lol that's a VBA script for a macro in Excel. It finds something I specify and copies it from one sheet to the next (filtering :)) So I'm trying to add a way to make it filter another thing at the same time...say a word and a number. From field 18. Only problem is when I put Field:=18, criteria1:"XX" It breaks at Field:18. Idk why. I just need to filter two things out.

you should put the actual code you're trying to run. not a skeleton with the request to add to it.

i at least troubleshoot better when i can see the erroneous code.

DJ_MikeyRevile
04-18-2013, 11:36 PM
excel blows balls, use it every day. Try using the formatting tool for that specific cell

Assassin
04-19-2013, 08:19 AM
That is the macro's code in it's entirety. It doesn't have a form or anything nothing to push (which is wierd for VB I know) but I just put that in Excel's developer area and run it and goes.

Patmonster
04-19-2013, 10:22 AM
That's weird. lol. What is this for? haha.

ActiveSheet.Range("$A$1:$C$10000").AutoFilter Field:=1, Criteria1:="XX"

You said it breaks when you put "Field:=18" does it break with your put "Field:=1"?

Assassin
04-19-2013, 10:45 AM
Nope Field:1 works fine (it basically says Row A in Excel) and I can filter it to be "Name of person" or I can have a number "<=80" and it works but if I add in a second one so it says Field:1 blah blah, AND Field:=18, "number here" it breaks.

---------- Post added at 10:45 AM ---------- Previous post was at 10:31 AM ----------

I think because the code is pasting it into a new sheet..and I have the code saying active sheet it is checking the "newly created" sheets range of cells and coming back with null's. I may have to find the command to go back to the previous sheet.

Assassin
04-19-2013, 01:09 PM
Ok close this please Maynard, Cyber or whover else. I got it.

acolyte_to_jippity
04-19-2013, 05:41 PM
Ok close this please Maynard, Cyber or whover else. I got it.

no. NO!

you post what the fuck you did to fix this.

as an IT proffessional, there is NOTHIGN more annoying and/or asshole-ish than someone having a problem, posting on a forum for help, and then later saying "never mind i fixed it" WITH NO EXPLAINATION.

Patmonster
04-19-2013, 05:48 PM
omg thank you! :banghead:
As a fellow coder, I would like to see this as well. While I do not use excess very often I do wonder what was causing that.

Assassin
04-20-2013, 02:21 AM
Apparently the code couldn't handle over like 912 cells at a time or some shit unless you made the constructor different. So I switched to the different one, took away all the selects except for those for the sheet name and the cells to copy and walla.