+ Reply to Thread
Results 1 to 3 of 3

Help for Beginner - Macro with IF Statements

  1. #1
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Red face Help for Beginner - Macro with IF Statements

    Hello,

    I would like some help in creating a macro. My spreadsheet has four cells in which numbers can be entered: B6, B8, B10, or B12. Not all of the cells require a number. I have created an Excel formula with multiple IF statements. The formula picks up the numbers entered in the cells and puts them in another cell, B27. The number in B27 will either be from one of the aforementioned cells or a combination of two of the cells. I would like to create a macro for a button so that when the user clicks on the button the numbers either appear in B27 or, if the number is too long (i.e., exceeds 30 characters) a message box will appear telling the user that the numbers entered need to be changed. The Excel formula I would like to convert to VBA is below. It has the limit of 7 IF statements that Excel allows, but I would like the macro to include the 8 IF statements below. If am very, very green to VBA programming and do not know where to begin with this and would appreciate any help anyone can give. Thank you.

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

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Help for Beginner - Macro with IF Statements

    First of all your current formula is not written in a proper way. Tell us what is your actual conditions in your formula?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Re: Help for Beginner - Macro with IF Statements

    Thank you for responding, and I apologize. I see how this was not the best way to provide the information. Does the following make better sense?

    • If a number is only in cells B6, B8, or B12, that number alone should appear in cell B27.
    • If numbers are in B8 and B10, both numbers should appear in B27 separated by a forward slash (i.e., B8/B10).
    • If a number is in B10, it is expected that a number should also be entered in either B6 or B8. Therefore, if a number is in B10 but not in B6 or B8, the user is notified when they click on the message button. The message would be "You have entered only an Order number. Please enter either an appropriate Schedule No., GWAC No., IDIQ No., or BPA No, or make any other necessary corrections."
    • If a number is entered in all cells (B6, B8, B10, or B12), then button message will say, "You have entered too many numbers. Please delete the extraneous numbers."
    • If the number that shows up in B27 exceeds 30 characters, button message will say, "The contract number exceeds 30 characters. Please shorten the number by entering it directly in B27."

+ 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. IF Statements (Beginner)
    By loganc123 in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 02-03-2016, 12:42 AM
  2. Macro for a beginner
    By fac1987 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 02:14 PM
  3. Macro Beginner!!
    By R1ck in forum Excel General
    Replies: 4
    Last Post: 12-12-2011, 07:46 AM
  4. macro for beginner
    By sanlen in forum Excel General
    Replies: 2
    Last Post: 06-23-2010, 12:45 AM
  5. Beginner at macro needs help
    By embe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2007, 07:16 AM
  6. [SOLVED] Macro for a beginner
    By Masha in forum Excel General
    Replies: 2
    Last Post: 02-14-2006, 02:45 AM
  7. macro beginner
    By Erica in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2005, 12:05 PM

Tags for this Thread

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