+ Reply to Thread
Results 1 to 7 of 7

Need a macro to introduce multiple conditions. IF

  1. #1
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    Need a macro to introduce multiple conditions. IF

    'm having trouble on building a multiple condition code. Here's what i need to do:

    these conditions must run down trough a list.

    When column H already have a date, do nothing to column H;
    When AW (date column s) is empty do nothing to column H;
    When column J is written "Date closed" do nothing to column H;
    when column I is written "Control", cell in column H egal to cell in column AW
    When column Z is written "Transport to STK/FORN" insert date 2 days in front of today in column H
    If none of the above cell in H = cell in AW

    The bottom conditions cannot overwrigh the top conditions.

    code:

    Please Login or Register  to view this content.
    I tried to lock the cells in the first condition so the conditions below won't overwrite these first conditions.

    I am sorry for the bad english.
    Last edited by JBeaucaire; 06-21-2016 at 12:48 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need a macro to introduce multiple conditions. IF

    This macro seems to do the steps you've outlined:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    Re: Need a macro to introduce multiple conditions. IF

    ElseIf UCase(Range("Z" & rw).Value) = "TRANSPORT TO STK/FORN" Then
    Range("H" & rw).Value = Date + 2


    This condition, it didnt insert the right date. It copied from column AW.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need a macro to introduce multiple conditions. IF

    That's not possible, based on that code. I'm going to guess it actually skipped that line section copied from AW.

  5. #5
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    Re: Need a macro to introduce multiple conditions. IF

    isnt there an "DateAdd" function? Saw some tips on google, here one of the responces:

    http://excel-macro.tutorialhorizon.c...tions-dateadd/

    I tryed this on the conde:

    ElseIf UCase(Range("Z" & rw).Value) = "TRANSPORT TO STK/FORN" Then
    Range("H" & rw).Value = DateAdd("d", 2, Date)
    Else
    Range("H" & rw).Value = Range("AW" & rw).Value

    but allso no succes =/
    Last edited by JBeaucaire; 06-21-2016 at 01:45 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need a macro to introduce multiple conditions. IF

    The DateADD thing isn't needed. Date+2 does the job.

    Working blind, I'm going to guess that line of code is being skipped and it's the NEXT section that is updating based on the AW value.

    Something in column Z is not what it appears to be. Hidden spaces or something, perhaps?

  7. #7
    Registered User
    Join Date
    06-21-2016
    Location
    Brazil
    MS-Off Ver
    2002
    Posts
    23

    Re: Need a macro to introduce multiple conditions. IF

    I looked for hidden columns, but there was none. I copied the value i wanted of Z to the code so i wouldnt miss any spaces or misspelling, but still it brings me the value of AW instead of date+2.

+ 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. Replies: 2
    Last Post: 01-14-2016, 03:53 PM
  2. [SOLVED] Macro for data present in multiple rows and columns following multiple conditions
    By macrolearnerkk in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-07-2015, 11:20 AM
  3. [SOLVED] When recording a macro is it possible to introduce a time delay in 2 consecutive moves?
    By abkundargi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2015, 12:32 AM
  4. Need to introduce macro's that will minise time at month-end
    By moe1986 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-19-2014, 04:39 AM
  5. [SOLVED] VBA Macro Help -- Cut/Paste EntireRow with Multiple Conditions
    By robotfo0d in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2012, 04:43 AM
  6. Cannot record with macro with sumproduct with multiple conditions
    By melvyndb in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-18-2012, 11:00 AM

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