+ Reply to Thread
Results 1 to 6 of 6

need help to add a new row to a table automatically

  1. #1
    Registered User
    Join Date
    01-17-2020
    Location
    israel
    MS-Off Ver
    2015
    Posts
    2

    Post need help to add a new row to a table automatically

    Hi there, i am new to vba coding and i need some help with a code i made.
    I am trying to build a code that will add a new row to a table automatically if the current month is greater then the newest month that is currently in the table
    for example if the latest row shows info for December 2019 than the code will add a new row for January 2020. here is the code i made:
    Please Login or Register  to view this content.
    When i try to run it, it says
    "run time error 13:
    type mismatch"

    and highlights the if function line...

    Please if anyone can tell me what i am doing wrong it will be of great value to me!!
    Last edited by hereisjohny; 01-19-2020 at 06:19 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Hi,

    the right syntax order is Cells(Row#, Column) as explained in the VBA inner help …

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,298

    Re: new to vba, need some help with if code

    Please Login or Register  to view this content.
    As per Marc L ... the n represents row, the 1 represents column
    https://www.wallstreetmojo.com/vba-cells/
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: new to vba, need some help with if code

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    I did it for you this time

  5. #5
    Registered User
    Join Date
    01-17-2020
    Location
    israel
    MS-Off Ver
    2015
    Posts
    2

    Re: new to vba, need some help with if code

    Quote Originally Posted by sintek View Post
    As per Marc L ... the n represents row, the 1 represents column
    yeah the row index is the variable...
    it is supposed to look for the last row in the table and if the month in that row is smaller then the current month then it will preform the code inside the if loop..

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,298

    Re: need help to add a new row to a table automatically

    When i try to run it, it says
    "run time error 13:
    type mismatch"
    Please Login or Register  to view this content.
    See the correct code in post 3

+ 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] Code to display text & code in a combo list, but display only code when selected
    By kdestef1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2019, 06:07 PM
  2. [SOLVED] Need help with VBA code. Tons of code seperated in two, second part of code doesn't work.
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-30-2015, 11:46 AM
  3. [SOLVED] Pattern Building VBA Code - Working code, would like to use cleaner code
    By Benisato in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2015, 03:05 PM
  4. [SOLVED] Excel VB code. Message pops up while code running asking question. Code must not wait.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2014, 06:10 AM
  5. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  6. Replies: 2
    Last Post: 03-09-2013, 04:30 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