+ Reply to Thread
Results 1 to 4 of 4

vba for nested if formula

  1. #1
    Registered User
    Join Date
    12-19-2010
    Location
    mumbai, India
    MS-Off Ver
    Excel 2003
    Posts
    71

    vba for nested if formula

    Hello All,

    I am stuck in a macro where I need a vba code.

    my file looks like this:

    A B C
    10/5/2016 JFM 11/04/2016
    15/1/2017 APJ
    02/2/2015 JFM 05/8/2017
    28/3/2016 OND
    05/1/2017 JAS

    Requirement: wherever there is blank cell in columns "C", it should consider date from column "A" of the same row.

    Result should look like below table:
    A B C
    10/5/2016 JFM 11/04/2016
    15/1/2017 APJ 15/1/2017
    02/2/2015 JFM 05/8/2017
    28/3/2016 OND 28/3/2016
    05/1/2017 JAS 05/1/2017

    help me with a vba code.

    Thanks

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: vba for nested if formula

    Try this

    Please Login or Register  to view this content.
    which could also be written:
    Please Login or Register  to view this content.
    Note - this code only works if cell in column C is truly blank
    Last edited by kev_; 05-23-2017 at 06:49 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: vba for nested if formula

    Do you really need VBA. A temporary helper column D with

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    copied down then copied and pasted as values back to column C would do it. In fact your macro could code that, deleting the helper column D at the end.

    Alternatively if you are using VBA don't use a loop to examine each cell in turn, first filter column C for blanks and copy the code

    Please Login or Register  to view this content.
    to all the filtered rows using the SpecialCells(xlCellTypeVisible) syntax to only copy to the visible rows.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: vba for nested if formula

    applying Richard's suggestion, then my code becomes:
    Please Login or Register  to view this content.

+ 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. nested if formula
    By logisticsexcel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-30-2016, 03:15 AM
  2. Replies: 2
    Last Post: 08-24-2014, 04:56 AM
  3. [SOLVED] Nested IF formula help
    By ertweety in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-06-2014, 05:10 PM
  4. Need help in nested formula
    By gerard_gonzales33 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-06-2012, 03:38 AM
  5. Replies: 2
    Last Post: 10-08-2009, 09:51 PM
  6. help on a nested countif/nested if formula
    By vickiemc in forum Excel General
    Replies: 2
    Last Post: 08-13-2008, 08:29 AM
  7. Nested Formula
    By lapta301 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-11-2005, 08:38 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