+ Reply to Thread
Results 1 to 6 of 6

Repeat VBA Formula For Multiple Rows

  1. #1
    Registered User
    Join Date
    05-18-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Repeat VBA Formula For Multiple Rows

    Hi All,

    I was wondering if you'd be able to help me with the following.
    I've been trying to lock a range of cells (H6-M6) whenever N6 isn't JM, DS, SD or SJ (This is a drop down menu). This has actually worked with the below code. However, I now want it to be applicable to the rows below that as well, so H7-M7 to be locked when N7 is not JM/DS/SD/SJ to row 60/70 more or less. I was thinking of copying the code and just changing the row numbers but I reckoned that's probably not the way to go.

    Aditionally, I've been trying to clear out H6/I6/K6/M6 of any content as soon as JM, DS, SD or SJ is cleared from N6 and goes back to blank. And then for the rows below as well, obviously.

    Would anyone be able to help me with both or one of these matters?

    It would be greatly appreciated

    Thank you


    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Repeat VBA Formula For Multiple Rows

    Hi there,
    Tried to achieve Your expectations.
    Here is the code:
    Please Login or Register  to view this content.
    Copy that code to the worksheet_change event in VBA.
    For primary set-up (in new workbook), run this code:
    Please Login or Register  to view this content.
    An here is the file:
    Book1.xlsm

    Done on 100 rows, but can be how many You want. Just expand the range in 'LockCells' SUB.

    Hope it helps
    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

  3. #3
    Registered User
    Join Date
    05-18-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Repeat VBA Formula For Multiple Rows

    Hi there,

    Sorry for the late response, was kept busy. This code seems to be getting me there but there's 2 things that are not going as I would like them to.

    1. Rather than deleting the entire row contents up to row M, i'd like to see only columns H, I, K & M of the target row cleared. J & L have formulas in them which I need to keep there at all times.

    2. The unlocking works perfectly, however I'd like the cells to re-lock after N is no longer showing JM/DS/SD/SJ.

    Would you be able to help me?

    Thank you!

  4. #4
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Repeat VBA Formula For Multiple Rows

    Hi there,

    locking fixed and 'clearcontents' adjusted:
    Book1.xlsm

    Also I found that dropdown has to be restricted only for those 4 strings so I adjusted dropdown properties.

    See if this is correct.

  5. #5
    Registered User
    Join Date
    05-18-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Repeat VBA Formula For Multiple Rows

    You are a star!

  6. #6
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Repeat VBA Formula For Multiple Rows

    No, I am not a star...

    You are welcome!

+ 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] How to repeat a macro in multiple rows of a sheet?
    By rgoodman in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-01-2013, 09:07 AM
  2. How to repeat creating individual charts from multiple rows
    By central in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-12-2012, 01:55 PM
  3. repeat if/then for multiple rows
    By yayfalcor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2009, 09:45 PM
  4. How to repeat multiple rows as a header - each page of worksheet?
    By laurandc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-17-2006, 10:05 AM
  5. [SOLVED] Repeat printing rows in multiple worksheets
    By KevinG in forum Excel General
    Replies: 13
    Last Post: 05-23-2006, 04:10 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