+ Reply to Thread
Results 1 to 3 of 3

Code to loop fill cells from two other cells in row

  1. #1
    Registered User
    Join Date
    11-05-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    2

    Code to loop fill cells from two other cells in row

    Hi, I am new to macros and vba and have got stuck trying to write a loop, please could someone help with the code?
    I want to complete a loop while there's a value (it's a text string) in the first column, starting from row 7 and going down.
    I want to put a value in months in column D which is the difference between the dates in columns B and C; if there is no date in B or C for that row, I'd like to leave the 'months' column empty. I know you can use 'DateDiff' but I can't work out how to reference the cells in columns B or C.
    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Code to loop fill cells from two other cells in row

    could you send a non-sensitive but ilustrating sample in excel showing a sample input and the corresponding output?

  3. #3
    Registered User
    Join Date
    11-05-2014
    Location
    London, England
    MS-Off Ver
    2003
    Posts
    2

    Re: Code to loop fill cells from two other cells in row

    Certainly:

    BE1-026 28/10/2013 17/12/2013
    BE1-025 30/10/2013 16/12/2013
    BE1-024 24/09/2013 24/07/2014
    BE1-023 22/05/2013
    BE1-022 24/07/2013
    BE1-021 28/06/2013
    BE1-020 13/05/2013 04/08/2013
    BE1-019 19/04/2013 02/02/2014

    BE1-XXX is a code for the person in Column A, first date is column B, second column C. In column D I would like the difference in months between the two dates. It doesn't matter too much if 1st Nov- 31st Dec and 29th Nov-2nd Dec both show as 1 month.

    Thanks in advance.

+ 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. Changing my code to loop through a list of cells (lots of reference cells)
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2014, 12:31 PM
  2. [SOLVED] Code to fill down 2 cells to last row
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2014, 12:19 PM
  3. Code to fill down cells
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2014, 01:41 PM
  4. [SOLVED] Help fix my loop to fill in blank cells down a row
    By mellowmarshall in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 01:29 PM
  5. vba Do while loop to fill cells
    By Hendrik Soede in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-23-2013, 10:46 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