+ Reply to Thread
Results 1 to 15 of 15

Run only if cell in column A is within range

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Run only if cell in column A is within range

    Hello,

    I've got a macro that works great. It posts the username and time in cell H and I if any values in that row are edited.
    I now want to modify this code to post username and time on edits, only if the value in cell A is between 1000000 and 39999999

    Here is the code i want to modify:

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    When you say "the value in cell A", do you mean the value in column A that is in the same row that you are posting the username and time? If so, then this should work below.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    Wow.. That worked like a charm!!!

    What if I would like to automatically delete an entire row where the value in column A is not within the same range? (only from Row 4 and down)
    Last edited by vonrainer; 06-28-2014 at 11:44 AM.

  4. #4
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    I have never used the "Target" command before, so I can't guarantee that the below delete command will work, but this is how you would set it up.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    Hi,

    Worth a shot, but it did not work. I might as well just create a new macro, and this is what I have tried (ended up with runtime error 424: object required):

    Please Login or Register  to view this content.
    Any suggestions on how to modify the code to work?

  6. #6
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    Ok, I've gotten a bit closer to what I want. The following code works, but it includes all cells in column A. How can I modify it to only run from cell A4 and down?

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    I have never been too good at event change macros. I think this requires a workbook_change event, but I can't get it to work.

    If you manually run the macro when you make a change, I can help with that. Otherwise, I don't think I can be of any further assistance and I would suggest posting another thread asking for help with a change event.

  8. #8
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    Using the code you just added, try adding another IF statement

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    I plan on running this macro from a button, so workbook_change is not neccessary.

    Se the post above (#6), where I have almost reached my goal. Just need the code modified to work from Row 4 and down

  10. #10
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    The additional statement in post #8 has an IF statement that checks to see if "i" (the row number) is greater than or equal to 4. See if that works.

  11. #11
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    You Sir, just made my day. It now works perfectly!

    There is just one more addition to this macro I need (sorry I left that out earlier)
    - How can I "hardcode" the macro to run on a different sheet?

    The button for the macro will be on sheet named "Inbox", but the macro (deletion of rows) should occur in four different sheets
    Think maybe some with-worksheets code are needed?

    Run from sheet:
    "Inbox"

    Run in sheet:
    "Norway"
    "Romania"
    "Aproval"
    "Solved"

  12. #12
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    Do you want it to run in the "Norway" sheet, and then continue to the next three? Or you do you want to specify it to run in only one sheet at a time?

  13. #13
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    Well... Not sure if I understood your question, but will try to answer anyways. Perhaps the best would be if it first ran in "Norway", and when that is complete run in next sheet and so on and so on. (run in all sheets from one button)

  14. #14
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Run only if cell in column A is within range

    Using your previous code, I added a select case to loop through and go to each worksheet automatically.

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Run only if cell in column A is within range

    Thanks! Worked like a charm!

+ 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] Got range of a cell, now modify that to be range of entire column
    By ShawnW in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-19-2013, 11:46 AM
  2. [SOLVED] Cond. formatting a column/Range, highlight cell in column/range if equal to specific text
    By DFrank231 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-19-2013, 03:35 PM
  3. Replies: 3
    Last Post: 02-13-2013, 04:05 PM
  4. Replies: 15
    Last Post: 06-27-2011, 08:58 PM
  5. If text mathces column 1 range, display value in column 2 cell
    By brillison in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-03-2008, 03:59 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