+ Reply to Thread
Results 1 to 5 of 5

Problem compiling code that identifies local maxima in a data series

  1. #1
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Problem compiling code that identifies local maxima in a data series

    Hi,

    Would anyone have an idea how to deal with this problem? It's a while since I last used VBA and what I am trying to do is essentially identifying local maxima of certain data points. That is:

    1. I have a series of data in a Range (a column) in order. I would like to identify local maxima which means, if the value in current cell is greater than the value in the previous cell and the value in the cell after it, I want this value to be placed just in the same row but in the column next to it.
    Otherwise, I want to leave the cell next to it empty and go to the next one.

    I wrote a code but it fails to compile due to a "Type mismatch" problem and I can't figure out what it is.. :/

    Thanks for all help!


    Please Login or Register  to view this content.

  2. #2
    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: Problem compiling code that identifies local maxima in a data series

    Hi,

    Why do you need a macro. A normal formula will do. i.e. with your list of data starting in A1, in B2 enter

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and copy down.
    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.

  3. #3
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Problem compiling code that identifies local maxima in a data series

    I actually need the macro since this is part of a larger code that is supposed to interpolate values (later on) between empty cells...

  4. #4
    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: Problem compiling code that identifies local maxima in a data series

    Hi,

    In that case just get the macro to populate B2:B... with the formula I gave you. i.e. something like

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    where Sheet1 is the sheet VB codename not the tab name

  5. #5
    Forum Contributor
    Join Date
    04-07-2013
    Location
    France
    MS-Off Ver
    Excel 2011
    Posts
    166

    Re: Problem compiling code that identifies local maxima in a data series

    Ok, good idea! Thanks a lot!

+ 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. Replies: 3
    Last Post: 07-06-2014, 08:38 AM
  2. Measuring difference between many local maxima/minima
    By Tim E in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-09-2013, 02:53 AM
  3. Locating multiple maxima within a data column
    By AlanDA66 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-13-2012, 12:33 AM
  4. Excel formula that identifies the next number in the series.
    By crazysniper in forum Excel General
    Replies: 3
    Last Post: 03-07-2012, 07:09 PM
  5. data compiling problem
    By adveda1 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-01-2007, 10:13 AM
  6. VBA code compiling problem...
    By face_actuary in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-08-2007, 09:35 AM
  7. [SOLVED] Problem in compiling code containing "$" char
    By Alain79 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-30-2005, 05:07 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