+ Reply to Thread
Results 1 to 6 of 6

Runing "Sample" add-in within a macro

  1. #1
    Registered User
    Join Date
    09-13-2008
    Location
    TX
    Posts
    4

    Exclamation Runing "Sample" add-in within a macro

    Hi there, long time reader first time poster...

    Excel 2007, Data- Analysis add-ins installed.

    I'm recording a macro to do gobs of copy/paste and column fills for me (filling a data analysis spreadsheet for different datasets in the same format), and interspersed in these copy/paste/autofill actions I occasionally recorded myself using the Sample add-in to make a list of every 6th entry in a column.

    When I run the macro, all begins as it should, until it gets to the first time I ran the add-in. When it gets there, I get the following error message:

    "Run time error '1004'. Method 'run' of object '_Application' failed"

    I have a suspicion that this has something to do with which window or button is active (based on my searching around) but I'm hoping someone can take a look at my code and give me something to go on.

    Here 'tis (note, its the first few lines of a LONG macro):
    Please Login or Register  to view this content.
    Its the
    Please Login or Register  to view this content.
    that causes the error.

    I've subscribed to the thread, so I'm ready to try any suggestions.

  2. #2
    Registered User
    Join Date
    09-13-2008
    Location
    TX
    Posts
    4

    update

    I've since changed the macro to autofill any range with
    Please Login or Register  to view this content.
    I've also cleaned it up some, and re-ordered some operations.

    Still the same error the first time it calls the application.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Could you explain what you're trying to do, instead of saying what doesn't work?
    Last edited by shg; 09-14-2008 at 12:08 AM.

  4. #4
    Registered User
    Join Date
    09-13-2008
    Location
    TX
    Posts
    4

    Smile

    Sure. Y'all will probably have a better solution than what I came up with anyway.

    I'm constructing a spreadsheet to process data from 8 water flow gauges logged every 10 seconds, round the clock. An event that I might want to graph could last as long as 24 hours, so I'm way oversampled for something of that length (conversely, usable events can be shorter than a half hour, so the resolution is good to have). The ultimate output is a graph showing the relative sum of these sensors' recordings over time.

    For the longer events, I'd like to sum my 10 second data points into one minute data points (or even coarser for a super long event) so that excel has to crunch fewer numbers to display a graph.

    My solution to this thusfar has been to create a column next to the data I'm interested in binning, and summing the same six cell blocks of data six times, then summing the next six cells of data six times and so on. For example 2 interations might look like this (column A is my data, colmn B is my binned data):

    A B
    1 9
    2 9
    3 9
    2 9
    1 9
    0 9
    0 2
    1 2
    0 2
    1 2
    0 2
    0 2

    After column B is auto-filled, I was trying to use the 'Sample' Analysis Tool to sample every sixth point from column B and produce a column C which would effectively be my new, binned data, ready for graphing.

    I hope that clears things up, the issue was that although I was able to do this manually while the macro was recording, its having trouble replicating it. I'm sure there's a better workaround, but you work with the tools you know...right? I'm interested to see what other solutions exist.

    Thanks, all.

  5. #5
    Registered User
    Join Date
    09-13-2008
    Location
    TX
    Posts
    4
    Anyone? I'm really stuck here, surely there's a different way to accomplish this, or a way to fix the code...

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Define:
    Data Refers to: the range containing the guage data

    nRow Refers to: the number of data elements to be summed (e.g., =6)
    Then put this into another column starting in the same row as the data and autofill down as far as necessary:
    =SUM(INDEX(Data, nRow * (ROW() - ROW(Data)) + 1):INDEX(Data, nRow * (ROW() - ROW(Data) + 1) ) )
    The formula will return a #REF! error when in runs out of data.
    Last edited by shg; 09-14-2008 at 11:51 AM.

+ 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. macro to create a macro?
    By jojotherider in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2008, 08:34 PM
  2. Macro for copy/insert into expanding table
    By Soslowgt in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-06-2008, 07:24 PM
  3. How to splitt texts into words? (collecting word and compounds)
    By wali in forum Excel Programming / VBA / Macros
    Replies: 53
    Last Post: 02-03-2008, 04:06 AM
  4. Conditional formatting macro (highlight macro)
    By c991257 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2007, 02:46 PM
  5. Need macro to move down & select next visible row
    By Fartnuckles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2006, 10:02 PM

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