+ Reply to Thread
Results 1 to 12 of 12

Multi function of actions from value in one cell

  1. #1
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Smile Multi function of actions from value in one cell

    I am asking for help with this VBA code. I got it to run to a point and it just stops with no error messages. I have run it through Debug with no errors. I am very new to VBA and would appreciate all help received. If you could also explain where I have made mistakes so I can keep learning how to write VBA code.

    The function of this sign in form is as follows:

    When entering number in column “A” it enters current time in column “D”. Then when an entry is made into column “K”, current time in column “E” and checks to see the value of the entry in column “K” is one of several choices “ATR”, “AV”, “BT”, “CO”, “DR”, “OT”, “NS”, “RLCC”, “RPCC”, “RLMO”, “RPMO”, “RLFW”, TA”, “ME”, “VI” then it places data into different cells or clears cells based off of the entry. I have attached a copy of the worksheet.

    Please Login or Register  to view this content.
    Thanks again for any help received !!!
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Multi function of actions from value in one cell

    Hey CourtTrouper,

    Starting to read your code. It looks like you need an "End If" just above your "Code runs to this point then seems to just stop"

    Indent your code in blocks of If and End IF to see what block you have missed ending.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Multi function of actions from value in one cell

    Courttrooper,

    Comment the line:
    On Error GoTo EndItAll

    so it looks like:
    'On Error GoTo EndItAll

    then rerun the code and note the code line producing the error. Post back.

    Maud

  4. #4
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Multi function of actions from value in one cell

    Thank you both for your help.

    I have applied both your suggestions and now It will run to the line

    Please Login or Register  to view this content.
    In which I found an entry error. I changed the lines to :
    Please Login or Register  to view this content.
    In this line all 3 columns need to be cleared if column “K” = “BT”. I don’t know how to accomplish this.

    If I jump past this bug I get a “Compile error: Argument not optional” at the first line that is”
    Please Login or Register  to view this content.
    Underlined part is in yellow and says “error Type mismatch” and I have no idea what is happening. Can you explain and tell me how to correct this please? Once I get this one fixed I can change all the others.


  5. #5
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Multi function of actions from value in one cell

    Sorry last reply did not show the underline so here it is again.
    Please Login or Register  to view this content.
    The Range in bold Has blue background which I placed in italics. I hope you can understand this. Thanks again for your help.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Multi function of actions from value in one cell

    Hey CourtTrouper,

    Each programming language is a little different. Your line of:

    If Target.Value = This or that

    isn't liked by VBA. Try this:

    If Target.Value = This OR Target.Value = That ... Then

    https://www.techonthenet.com/excel/formulas/or_vba.php
    http://www.excel-easy.com/vba/exampl...operators.html

  7. #7
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Multi function of actions from value in one cell

    Thanks for the help and the links. I can use them as another resource. I did write basic code almost 18 years ago so things have changed. I will make the changes and get back today to see if it works now.

  8. #8
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Multi function of actions from value in one cell

    I got it to run further but it still doesn't like my wording I think. No error codes just stops. I have one IF statements that have 3 ands and it won't run.
    Please Login or Register  to view this content.
    The next problem is with my attempt to follow your wording instruction and I probably have misunderstood. here is my old code
    Please Login or Register  to view this content.
    Here is My attempt at the new code.
    Please Login or Register  to view this content.
    Also is there some rule on when you put in an "End If" if you have a lot of If statements bunched together?
    Thanks again for all your help.

  9. #9
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Multi function of actions from value in one cell

    COURTTROOPER,

    Your code can be rewritten as:

    Please Login or Register  to view this content.
    which IMHO is a lot easier to follow than a very long If statement.

    HTH,
    Maud

  10. #10
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Multi function of actions from value in one cell

    Thanks Maud for your help. I now have 2 of the 3 problems working !!
    I have a question about rules of If statements. If you have a group of If statements do you need to put an End If after every one or can you just put one at then end?

    I still need guidance on the code that needs to clear contents of 3 cells if "NS" is selected in "L". this is the non working code I made. Could you look at it and tell me why it won't run please?

    Please Login or Register  to view this content.
    Thanks again for any help received.

  11. #11
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Multi function of actions from value in one cell

    CT,

    "If" statements can be written two ways: Line or block.

    Line "IF" statements do not need a trailing "End If"
    Please Login or Register  to view this content.
    Block "If" statements require and "End If"
    ex:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    HTH,
    Maud

  12. #12
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Multi function of actions from value in one cell

    Thank you all for your help!! The code works great and I learned much from 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. Multi Cell Search/Pull Function.
    By CanadianFrodo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2017, 05:18 AM
  2. Counting many multi-week actions to find how many open per day
    By PhilCoffin in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-24-2014, 05:51 PM
  3. [SOLVED] Excel 2007 : Different Actions from variable numbers in a Cell
    By whitywhit in forum Excel General
    Replies: 10
    Last Post: 07-15-2012, 12:39 PM
  4. Macro to loop actions until empty cell
    By RobbieMoulton in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-29-2011, 02:59 AM
  5. how to prevent users able to perform cell actions except cell range selection
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-08-2010, 09:47 AM
  6. Actions between user actions
    By Indiana Epilepsy and Child Neurology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2006, 12:45 PM
  7. Replies: 3
    Last Post: 06-07-2005, 09:05 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