+ Reply to Thread
Results 1 to 16 of 16

Need help tweaking macro

  1. #1
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Need help tweaking macro

    I have the following macro which automatically hides rows that contain blank cells within a given range of columns:

    Please Login or Register  to view this content.
    How to I edit the macro to make it select every other row from B to O? I need a macro that only looks at B,D,F,H,J,L, and N and then a second macro which looks at C,E,G,I,K,M, and O.

    Thanks so much!
    Last edited by mlancaster24; 12-08-2015 at 12:29 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help tweaking macro

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Thanks so much for your hasty reply. Can you clarify how I differentiate the 2 macros? am I supposed to plug in values into the third macro you provided? I'm so sorry, I'm a newbie to VBA and need to be hand-held

    Thanks again!

  4. #4
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Need help tweaking macro

    I suppose you would want to connect a button or a hot key to the first two macros.

    Also some administrative stuff...

    please use the code tags when entering code. (select the text and press the # above where you type)

    And give the thread a meaningful title - almost everyone who posts a thread here needs help tweaking a macro so it is a very bad term for people to search whether they are trying to help you or to benefit from any insights that might come from the discussion.

    I also suggest you don't call hiding rows "deleting rows" - it is unnecessarily confusing if you go back to it at a later stage.

  5. #5
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    Thanks for the pointers! Can you explain how the first 2 relate to the 3rd one? I need two separate macros, how do the first two relate to the last one? I'm not sure how to connect them.
    Last edited by mlancaster24; 12-07-2015 at 07:17 PM.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help tweaking macro

    The two short macros call the main macro.

    If you run "DeleteB()" it passes 2 to the main macro as the variable t, if you run "DeleteC() it passes 3 to the main Macro.

    The main macro looks at the cells from t to 12 + t in steps of 2 and counts the blanks.

    If 7 blanks are found in a row then the row is hidden.

  7. #7
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    Thank you @mehmetcik! Do I need to create three separate macros then? 2 short macros and 1 main macro? Or do I just create 2? Sorry as I said I am very much a newbie. Need to read VBA for dummies

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help tweaking macro

    I created the three Macros for you.

    if you call DeleteB() it will count blanks in B to N looking at every second cell

    if you call DeleteC() it will count blanks in C to O looking at every second cell

    the selected macro will then hide the empty rows.

  9. #9
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    I mean in the Visual Basic window where you paste code? Do I have to paste each code in a separate window?

  10. #10
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    I posted the code as dictated by forum rules, thanks!

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help tweaking macro

    No all the code can be in a single macro module.

  12. #12
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    Thanks! I tried running this but I am getting an error:

    Capture.JPG

    Could you possibly edit the code?

    Thanks so much again for all your help it is much appreciated!

  13. #13
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Need help tweaking macro

    Hi mlancaster24,

    Try replacing this line of code...

    Please Login or Register  to view this content.
    ...with this does the job:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  14. #14
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help tweaking macro

    Have you used t somewhere else in the macro?

  15. #15
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Need help tweaking macro

    Have you used t somewhere else in the macro?
    It's being duplicated in the DeleteBlankRows macro as t is a required parameter for the macro and then there is a t variable.

  16. #16
    Registered User
    Join Date
    11-10-2015
    Location
    San Francisco, California
    MS-Off Ver
    2013
    Posts
    11

    Re: Need help tweaking macro

    Thanks Trebor76 and mehmetcik. Replacing the line of code fixed the error, but I just realized it is hiding more than I need it to. Rather than hide the row if there are 7 blanks total, I need to hide the rows only in which all 7 of the every-other-rows are blank, if that makes sense. For example, if the first 7 columns from B-H are blank, the macro should not hide this row because it was not every other row that was blank. It should only hide the row if all columns B,D,F,H,J,L,N are blank OR all columns C,E,G,I,K,M, O are blank. I hope this makes sense, please provide code if possible, thanks so much again for your help.

+ 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. Need help in tweaking VBA Macro
    By vijey18 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2014, 11:36 AM
  2. [SOLVED] Macro tweaking and better way to import text file using VBA
    By zaska in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 03-26-2014, 08:29 PM
  3. [SOLVED] Tweaking an Excel 2003 macro
    By nharpaz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2013, 05:03 PM
  4. Tweaking of Macro Code to sort rows
    By swoosh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2012, 02:14 PM
  5. 'SEARCH' Macro Needs Some Tweaking
    By gnrjess in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 12:34 PM
  6. Tweaking an Outlook email Macro in Excel
    By John V in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2006, 05:25 PM
  7. Tweaking a Macro to Count Words
    By PGiessler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2006, 07:45 PM

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