+ Reply to Thread
Results 1 to 9 of 9

Macro to put in year in column

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,119

    Macro to put in year in column

    Hi I need a macro to put in year in column A. 2 cells under the name of the country. And beside the months in column B.
    When there is a space in the months in column B. It have to count down the year before. Again beside the months in column B.

    When it comes to the next country in Coulumn A. It have to do the same for the next country.
    Reason why i need a macro, is because the years count down can be variable for each country. It have to start with the present year, for every country.

    I have put a test file and you can see it in sheet 2 what i want. I have added in column A for the first year, how i want it to look.

    Please have a look and maybe better to understand if you see the test file.
    And you can see it in sheet 2

    I use excel 2003

    Thanks in advance

    Abjac
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Macro to put in year in column

    Try this.

    The code tests for a new country when a cell in column A is filled and the same row in column B is empty.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,119

    Re: Macro to put in year in column

    Alphafrog this is a brilliant code. I just checked it in a bigger sheet with many countries and many variables. And it works all the way.
    I only have a little problem now in layout.
    Its the same problem the countries and rows can be variant depends on what time/month i pull out this file.
    I need to delete all the numbers in column C,D,E which are outside the rows with country(A) and months .

    If you see in test sheet there is some numbers there. I know i need macro for that, because the output can be variant.
    So if you can help with this one also would be really great. Then i have a clean layout with all countries to work with.

    For now thanks allot ur code is brilliant. Dont know if i need to start a new thread, but i suddenly realized that this is same problem.

    Please have a look if you have time alphafrog, but for now thanks for this code, its great.

    Sincerely

    Abjac

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Macro to put in year in column

    So if both A and B are blank then clear the row in C:E? Is that correct?

    If yes...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-22-2014 at 03:54 PM.

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,119

    Re: Macro to put in year in column

    That was correct Aplphafrog. Its just tested on the big sheet. It works again Brilliant. Its 2 great codes. Thanks allot i hve now a clean layout, where and when i pull this out. Really great. Thanks allot

    Sincerely
    Abjac

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Macro to put in year in column

    You're welcome. Glad it works.

    Note: the clear C:E bolded code only works after the years are filled in column A.

  7. #7
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,119

    Re: Macro to put in year in column

    Ahh sorry just saw one little thing now. If there is a country name in column A i need to clear the number in that row in column c.
    The other works fine, but out for each country not the first the others/next i have a number also in column c.
    Can you manage this one also.

    Will be great just saw it now.

    Please if time have a look on this one.

    Thanks

    Abjac

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Macro to put in year in column

    Quote Originally Posted by abjac View Post
    The other works fine, but out for each country not the first the others/next i have a number also in column c.
    Hugh?

    This will clear C:E for all blanks in column B (regardless of column A).
    Please Login or Register  to view this content.



    Otherwise, please explain.

  9. #9
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,119

    Re: Macro to put in year in column

    Hi Alphafrog. Just was out here. I checked it now in the big sheet and all are just perfect. Thanks allot for your effort. It works just perfect.
    Have a nice evening.

    Thanks

    Sincely
    Abjac

+ 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. [SOLVED] I have the day and month but not the Year-need a macro to calculate the Year
    By iplayball in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-31-2013, 01:31 AM
  2. [SOLVED] Macro to Retrieve Data with Start Year and End Year
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2013, 01:09 PM
  3. If Column A Month and Year = ColumnB Todays Month and Year then send email
    By HACCStaff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2013, 12:47 AM
  4. Replies: 0
    Last Post: 10-23-2012, 11:44 AM
  5. Replies: 3
    Last Post: 12-30-2010, 07:24 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