+ Reply to Thread
Results 1 to 5 of 5

Help with function in VBA

  1. #1
    Registered User
    Join Date
    05-23-2018
    Location
    Albany,NY
    MS-Off Ver
    13
    Posts
    2

    Help with function in VBA

    This is very basic question on funcion writing. I cannot get the syntax right.

    I want to check a cell value in this way:

    =IF(B4<100%)

    Then change a date value:

    NewDateValue=DATE(YEAR(A1),MONTH(A1)+1,DAY(A1))

    write NEWDateValue to cell

    I would greatly appreciate help with this. Thanks!

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Help with function in VBA

    e.g
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-23-2018
    Location
    Albany,NY
    MS-Off Ver
    13
    Posts
    2

    Re: Help with function in VBA

    Here is what I wrote and I am getting #value error

    Function ChangeStartDate(PercentComplete)
    If (PercentComplete < 100) Then

    newdatevalue = DateAdd("m", 1, [F1])
    [K1] = newdatevalue
    End If
    End Function

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Help with function in VBA

    1)
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    2) What are you really trying to do?
    Better explain in words.
    my guess.
    Please Login or Register  to view this content.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help with function in VBA

    Hi DogLover and welcome to the forum,

    The value of a function is returned by using the name of the function itself. You need to end a function by setting something to the name of the function.

    Does this help? See where Jindon does this above.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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. COUNTUNIQUE Function in Google Sheets; Excel lacks a direct counterpart to this function?
    By PivotTablePSHomage in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2018, 05:27 AM
  2. Replies: 2
    Last Post: 04-23-2017, 12:04 AM
  3. Calling function inside function. (aka nested function)
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 05:58 AM
  4. VBA code for custom function that returns detail results of array function
    By onechipshot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2015, 06:30 PM
  5. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  6. Replies: 1
    Last Post: 03-21-2012, 11:22 AM
  7. Replies: 2
    Last Post: 03-20-2009, 01:29 PM

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