Consulting

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 21 to 40 of 42

Thread: Filter out dead columns

  1. #21
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Another option to run it, would be to press Alt + F8, choose desired Macro, press Options and assign it a shortcut key (eg K or M). Then, every time you run that code you may do so by pressing Alt + K (or whatever key you assinged it.

    You can make this even more *global* by saving the macro to your Personal.xls file, which is Excel's global macro. This means you can call these procedures from any workbook w/o having to re-input the code into each book. One time for any file on that machine. If you don't have a personal.xls or would like help setting one up, post back, there are a couple of ways.

  2. #22
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Eddie,
    As an option, the array could show the columns you wish to keep, with all others deleted, if this would be easier to manage, please let me know.
    MD

  3. #23
    VBAX Regular
    Joined
    Jul 2004
    Location
    Wellington, New Zealand
    Posts
    37
    Location
    Quote Originally Posted by firefytr
    I experienced problems with Parry's
    No problem with recommending another macro as mine was more to show a different appoach using an array. Theoretically it should be the fastest operation as it avoids a second loop and selecting cells. However it would be hardly noticable in such a small dataset (max 256) so stick with MD's solution.

    For my personal understanding Zack could you advise what problems you had as it worked fine for me.

  4. #24
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Sure Parry, it didn't delete all of the specified columns. I don't have the macro on file, but the first one in the array (BadOnes) it didn't delete, for me, was ""Cntr"". I'm not sure why this happened, it may have been me. I just tried a copy/paste and may have gotten something bungled up in the process, so it could have very well been me.

    As a side note, it was the fastest too.

  5. #25
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Here's the latest:

    I've gone into Macro's, and then Edit. I removed the other two codes, and saved it. Looking in the Macro options, the Macro is in All Open Workbooks. Is that the same thing as you mentioned, Zack?

    How do I go about changing the title of the macro? At the mement it's called eddiesTest.xls!RemColumns. Going to call it RemoveColumns.

    Ah, just looked to where it saves, the Temp folder

    I don't have a personal.xls, though as I'm on a network, I'll place this in my Profile.
    Can you help me create one?

    eddie
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  6. #26
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Created my personal.xls by following this:

    http://www.personal-computer-tutor.com/personalxls.htm



    Just need to figure out how to rename it (unless I can do it in Windows Explorer) then I can save it there, I'm thinking

    eddie
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  7. #27
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    You can rename it if you'd like, although it's usually strongly recommended against doing so. It's in your XLSTART folder. Find that and you find your personal.xls file. Those files will start automatically. Just be sure of what you want to name it, especially if there is a possiblility of other users coming onto your pc in the future, etc.

    I'm glad you got your file!! That's awesome!

  8. #28
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    OMG, Eddie. I used to work with her!! Thanks!!
    ~Anne Troy

  9. #29
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Eddie,
    To create a Personal.xls, go to Tools/Macro/Record New Macro; store in Personal Macro Workbook. OK ; then click in a cell and press the stop recording button. Close Excel and youre Personal.xls should be saved. Reopen Excel, Press Alt+F11 and you should see the Personal.xls project
    MD

  10. #30
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Zack, when I said to rename it in Explorer, thats because the title is RemColumns. I'll leave it as it is, as I may only have a few macros in there, and I have to write a method on how to edit/filter the report anyway, so can include the names.

    Will do some messing tomorrow when I'm at work, to get it all working okay. And when it is, I'll start a new thread with those other questions, and tell you when this is Solved

    MD, thanks for that. I created it using the link above, which was a different way. I assume its the same thing.

    Dreamy, its a small world

    eddie
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  11. #31
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by eddie5659
    I assume its the same thing.

    You got it. Personally, I'm of the opinion, that the way MD has described is the easiest and fastest way to create an instance (you only need one) of a personal.xls. Imho.

  12. #32
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Quote Originally Posted by mdmackillop
    Hi Eddie,
    To create a Personal.xls, go to Tools/Macro/Record New Macro; store in Personal Macro Workbook. OK ; then click in a cell and press the stop recording button. Close Excel and youre Personal.xls should be saved. Reopen Excel, Press Alt+F11 and you should see the Personal.xls project
    MD
    I've created it like you said now, as I can't seem to save the blasted thing. However, I still can't click Alt F11, so going to Windows | Unhide.

    Back soon
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  13. #33
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Alt+F11?
    Eddie...do you have a wireless keyboard? If so, hit the FLock key!
    Then try Alt+F11...
    ~Anne Troy

  14. #34
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Yes, its all working

    What I have done, and this is so I can bookmark this thread, is this. Deleted the personal.xls that I created. Saved it to the wrong place, as the link I provided is based on a standalone pc. Mine is now in:

    C:\WINNT\profiles\eddie\Application Data\Microsoft\Excel\xlstart

    Then, I don't know if this is the correct way or not, but its working when I shut Excel down, and reopen:

    I went into the Excel file that Zack sent me, and Tools | Macro | Macro. Then, I clicked on the one I wanted, deleted the other two, and then highlighted, and copied. I then opend the actual report I'm working on, Edit in Macro, and pasted the code. I saved it, closed down, saying Yes to Save.

    Also, my personal.xls opens all the time now, no need to unhide.

    Thanks ever so much, all of you.

    I'll post a new thread soon, but also waiting for a new meeting to find out if there's more.

    *edit* No wireless keyboard, but I think its because I'm on a network, and they've disabled it for some reason.

    Thanks

    eddie
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  15. #35
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Hiya

    I know this one is solved, but re-running my report from scratch to help on the new questions, and my Macro doesn't work

    Has it been changed?

    Sub RemColumns() 'MD
        Dim RemArray
        RemArray = Array("GC", "Cntr", "Whs", "QtyAll", "Uni", "itm", "B", "Prod", "Cat", "sts", "ShelfOK", "QS", "BPC", "La", "Res")
        Range("IV2").Offset.End(xlToLeft).Select
        Do
        For Each Rm In RemArray
            If UCase(ActiveCell.Text) = UCase(Rm) Then
                ActiveCell.EntireColumn.Delete
                Exit For
            End If
        Next
        On Error GoTo Exits
        ActiveCell.Offset(0, -1).Select
        Loop
    Exits:
    End Sub

    If not, I'll have a bit of a delve to see whats causing it.

    Thanks again

    eddie
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  16. #36
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hey Eddie,

    What is not working? Can you step through your code? Do this by going to the VBE (press Alt + F11), bringing up your relevant code module and putting the cursor inside your routine somewhere and press F8 to perform one line of code at a time. You can minimize your VBE window to half screen and watch Excel in the background to see what goes on. Does it fail at a certain line? If so, which one, and what error do you get? How are the results not as expected?

  17. #37
    VBAX Regular
    Joined
    Jul 2004
    Location
    Bradford, England
    Posts
    17
    Location
    Hiya Zack

    It doesn't fail, all lines that highlight are in yellow. It does loop on this bit:

    If UCase(ActiveCell.Text) = UCase(Rm) Then
        ActiveCell.EntireColumn.Delete
        Exit For
                End If
            Next
    Though is it supposed to? It goes If.., End..Next.. and then back to If, as in the start of the lines.

    What its not doing, is removing the columns, eg GC, Cntr, etc.

    This is a brand new sheet. I can't change the security settings (greyed out).

    Thanks again

    eddie
    Just go with the flow, like a twig on the shoulders of a mighty stream


    http://forums.techguy.org

  18. #38
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Eddie,
    Is the sheet protected?
    MD

  19. #39
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Maybe I'm not understanding. Do you not want it to exit the loop upon finding a matching condition (matching text)? If so, take out the Exit For portion. And sheet protection can be worked around easily enough, if that's hindering you.

  20. #40
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Eddie, Zack,
    The loop exits when a match is found, if you remove the "Exit For", it will continue to check all array elements, slowing (slightly) the routine.
    MD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •