+ Reply to Thread
Results 1 to 3 of 3

Delete a range of nearby rows where a cell = 0 (and loop to catch all)

  1. #1
    Registered User
    Join Date
    12-07-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Delete a range of nearby rows where a cell = 0 (and loop to catch all)

    Hi everyone

    I'm looking to fix my macro that I've created. I'm no good at actual 'programming' so I generally manually create a macro (by recording it) and then 'fix' it by changing bits of the code to suit.
    I've developed an 'Interview Guide Builder', where users select or type questions that they will ask in an interview (as many or as few as they want) and then press the 'generate' button and that will generate a 'user guide'.

    Here are two alternative 'processes' I want the macro to follow:
    Preferred alternative
    1. Unhide 'interview guide' worksheet
    2. Move or copy interview guide worksheet > create copy into new workbook [may be called Book 1, book 2, book 3 etc. depending on how many spreadsheets they've opened]
    3. re-hide interview guide worksheet from orginial workbook
    4. In new workbook, delete range of rows where cell A? = 0
    5. Save as PDF (Recruitment Interview Guide?) and save onto desktop (it will launch as a pdf)…. Will having a pdf with the same title be an issue?
    6. Exit Active Workbook (ie. New book created) > Do not save changes
    7.Activate PDF (Recruitment Interview Guide)
    ...Two documents left - original builder and pdf version of guide

    Alternative if the above process won't work - this is the process I've initially attempted to record
    1. Unhide 'nterview guide' worksheet
    2. Move or copy interview guide worksheet > create copy into new workbook [may be called Book 1, book 2, book 3 etc. depending on how many spreadsheets they've opened]
    3. re-hide interview guide worksheet from orginial workbook
    4. In new workbook, delete range of rows where cell A? = 0
    5. Protect Sheet (ie. No changes) in new workbook (no password required)
    ...Two documents left - original builder and new excel guide


    At the moment I'm up to Step 4 in either of the processes, but can't find a code to suit. Where the user hasn't input a question for that section (eg. they may only choose 4/15 questions for section 1), there are "0"s in those sections. I want to delete a range of cells (I've highlighted the range that will apply each time... it is a total of 7 rows each time (4 rows above the cell, the row the cell is in and 2 rows below the cell). It would need to loop to catch all the rows as they're deleted. At the moment, it only deletes the ones I manually selected... however, the user might choose more or less questions than that..Copy of Interview Guide Builder.xlsm.
    Can someone help me with this please? And if it isn't too cheeky, if anyone could assist with steps 5-7 in my first process... that would be AMAZING!

    I've attached an example of the file (please note the 'interview guide' is hidden currently) and my code that I've used is below:

    Please Login or Register  to view this content.
    Thank you!!!

  2. #2
    Registered User
    Join Date
    12-07-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Delete a range of nearby rows where a cell = 0 (and loop to catch all)

    Ok, so in the end I managed to solve it by playing around A LOT with different coding... thought I would post it for everyone...

    Please Login or Register  to view this content.
    I hope that helps someone!
    Cheers
    jdodz

  3. #3
    Registered User
    Join Date
    12-07-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Delete a range of nearby rows where a cell = 0 (and loop to catch all)

    Interview Guide Builder tester.xlsmSorry, forgot to add what the final workbook actually looked like...

+ 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. [SOLVED] Loop to Delete Rows and Shift Up on Cell Value
    By ayvee0 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2013, 11:04 AM
  2. Delete Rows Based On Cell Value (Without For-Next Loop)
    By dkcel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2013, 11:48 PM
  3. [SOLVED] Loop to delete rows on another tab and run until blank cell is met.
    By SillySox in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-14-2013, 11:09 PM
  4. [SOLVED] catch event insert a row or delete a row
    By Nader in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2006, 01:45 AM
  5. [SOLVED] How do I 'catch' a 'delete cells' event
    By Eric in forum Excel General
    Replies: 2
    Last Post: 03-09-2005, 04:06 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