+ Reply to Thread
Results 1 to 7 of 7

Find Highest 3x3 Sum

  1. #1
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Find Highest 3x3 Sum

    I have a dataset containing 3264 rows and 7640 columns, and I need to find the sums of each 3x3 grid, and eventually determine which are the top 10, by row & column header of upper left cell.

    I've attached a scaled down version with values from B2:P29. What would an efficient approach to this be?


    It's being used in conjunction with Latitude and Longitude, where each cell represents .01 degrees; actual headers are Lat and Long.
    Normally I'd just use a visual heatmap but these people want data with granular detail.

    To clarify, I'm mostly just looking for the list of all 3x3 grids and respective totals.
    Attached Files Attached Files
    Last edited by daffodil11; 02-04-2015 at 07:50 PM.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Find Highest 3x3 Sum

    I don't know how efficient this is but I think it would work. Using 2 loops 1 for row, 1 for columns, stepping every 3 and resizeing that range you can get your 3x3 grid. You then get the summation and input the base range (before the resize) along with the summed value into 2 arrays (the 2 parameters will end up having the same position in their respective arrays, for later use). After the ranges you loop through the array to determine what the top 10 sums which can, at the same time, give you their respective ranges.

    I didn't supply code because I wasn't sure if this way would be all that efficient. Figured I would offer you up a suggestion. If you want code let me know.

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find Highest 3x3 Sum

    I was making this much harder than it was. Thank you stnkynts.

    I will give the code a shot. I'm not terrible, but I haven't been coding long enough to figure out whats needed when I have nothing.

    2 for loops, incrementing by range of headers and rows, output maybe = wsfunction.sum(range(cells(r,c),cells(r+2,c+2)). Give me a little time to work through the logic.
    Last edited by daffodil11; 02-04-2015 at 08:07 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find Highest 3x3 Sum

    A whole lot of crashed workbooks later, I went with stnkynuts directions and built this, ultimately using DoEvents every 10 columns to prevent too much freeziness.

    Please Login or Register  to view this content.
    Also, I'm proud of myself and gave myself a gold star.

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

    Re: Find Highest 3x3 Sum

    Hi,

    Why not use relative addressing for all those sums and then do a large on the array of sums? See the attached:
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find Highest 3x3 Sum

    I tried, but the workbook got a little to unstable at 24,936,960 data points. And most importantly, I needed to be able to refer to the Row & Column Headers of each.

    Also, VB is AWESOME. I'm trying to learn it through immersion.

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

    Re: Find Highest 3x3 Sum

    Hi,

    Now that I see you wanted to practice your VBA, see this solution.
    I throw away any sum that isn't in the top 10 by doing the sort routine.

    I don't think this should take that long to do your big file.
    Attached Files Attached Files

+ 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. find 3 out of 5 highest cell #s
    By geo777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-20-2013, 05:22 PM
  2. Find the highest value below 400
    By FallingDown in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 11-20-2012, 05:35 AM
  3. [SOLVED] Find highest value in a row and return a value from a different row
    By VT_2000 in forum Excel General
    Replies: 2
    Last Post: 05-04-2012, 03:06 PM
  4. VBA code to find highest and 2nd highest number based in criteria
    By Michael007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-25-2011, 08:38 AM
  5. Replies: 2
    Last Post: 09-19-2008, 10:22 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