+ Reply to Thread
Results 1 to 3 of 3

Clean up my code!

Hybrid View

Mr ZN Clean up my code! 08-06-2013, 10:04 PM
Mordred Re: Clean up my code! 08-06-2013, 10:34 PM
FDibbins Re: Clean up my code! 08-07-2013, 12:19 AM
  1. #1
    Registered User
    Join Date
    07-30-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    20

    Clean up my code!

    Hi Guys,

    Looking for help cleaning up my VBA code. I have recorded and refined it to the point where everything is working beautifully. However, I would like to refine it so the code works with the sheets rather than selecting worksheets and cells directly. Would appreciate any pointers on how I can do this...

    Here is my current code:

    ' Copy paste unfiltered IRESS data from IRESS stock to IRESS options
    Sheets("IRESS Stock").Select
    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("IRESS Options").Select
    Range("A4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    ' Autofilter IRESS stock & IRESS options
    Sheets("IRESS Stock").Select
    ActiveSheet.ListObjects("Table6").Range.AutoFilter Field:=1, Criteria1:= _
    "=???", Operator:=xlAnd
    Sheets("IRESS Options").Select
    ActiveSheet.ListObjects("Table7").Range.AutoFilter Field:=1, Criteria1:= _
    "=??????", Operator:=xlAnd


    In regards to the first section of code, I have managed to find out that using the "With Worksheets("")" would be the first change but I am unsure how I would go about changing the Range("A3").Select & Range(Selection, Selection.End(xlToRight)) lines.

    In the second section I am unsure how to do it with auto filter.

    Any advice much appreciated.

    Thx

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Clean up my code!

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Clean up my code!

    also....
    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Code clean up
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 07:17 PM
  2. [SOLVED] code clean up
    By promoboy2 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-03-2012, 06:06 PM
  3. [SOLVED] Clean up code
    By Grilleman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-11-2012, 03:18 PM
  4. [SOLVED] VBA Code to optimize and clean data- clean out numerical/ or symbol
    By tracylsr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-05-2012, 04:21 PM
  5. VBA code clean up help
    By recon427 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-17-2012, 01:19 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1