+ Reply to Thread
Results 1 to 9 of 9

VBA Grid x Grid SUM problems

  1. #1
    Registered User
    Join Date
    11-25-2015
    Location
    UK
    MS-Off Ver
    2008
    Posts
    10

    VBA Grid x Grid SUM problems

    Relatively new to VBA but need some help with some work i have on.

    I have Grid 1 53x53 and grid 2 53x53 in different files and need a 3rd sheet to activate the Macro.

    the grids need to calc a1xa1 + b1xb1 etc for all the grid and then SUM the answer on the third sheet.

    Whilst not sounding so hard to complete, i have a folder of Files which contain different grid 1 and need the macro to run through the entire folder, doing the same calculation and providing me with the SUM of all cells on Sheet three.

    I also need it to provide the Name of the file next to the answer it gives me for each SUM so i know which is which.

    Is it even possible? and is it possible to specify different grid 2 if i need to in the future?

    Ste

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,611

    Re: VBA Grid x Grid SUM problems

    If you are open to a formula solution take a look at the following file, which incorporates the formula:
    Please Login or Register  to view this content.
    to retrieve values from the worksheets that are specified in B1 and D1 of sheet3.
    Grid x Grid Sum Problem.xlsx
    Let me know if you have any questions.
    Last edited by JeteMc; 11-30-2015 at 09:25 AM. Reason: Correcting an error in formula
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Registered User
    Join Date
    11-25-2015
    Location
    UK
    MS-Off Ver
    2008
    Posts
    10

    Re: VBA Grid x Grid SUM problems

    so far ive managed to get the code to work if Grid 1 and Grid 2 are on the same Workbook.

    But im struggling to get grid 1 to copy and paste into grid 2s work book.
    Please Login or Register  to view this content.
    Last edited by stedaley; 11-27-2015 at 09:28 AM.

  4. #4
    Registered User
    Join Date
    11-25-2015
    Location
    UK
    MS-Off Ver
    2008
    Posts
    10

    Re: VBA Grid x Grid SUM problems

    everything works up until i need to copy the Sheet 1 from the targetfile and paste it to the mypath file.

    plus this needs to be looped and work its way through the folder, and paste the results on a 3rd excel file

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Grid x Grid SUM problems

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    PS Can you add code tags when posting code?
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    11-25-2015
    Location
    UK
    MS-Off Ver
    2008
    Posts
    10

    Re: VBA Grid x Grid SUM problems

    Its all secure data, so the actual work books i cant send.

    File 1
    Where macro will be run from and will store data

    file 2
    53 x 53 grid of random numbers

    File 3
    53 x 53 grid of random number

    Run process.
    File 1 contain a button which when pressed allow the user to specify which version of file 2 they require to use to run against all version of file 3 which are contained in folder.

    once chosen, the folder is then specified where the files that want to be run against file 2 is selected. this contains many file 3's

    What i need to happen is that file 2 sheet 1 be copied and placed into each of the file 3s in turn as sheet 2. (I have the code to run what i need in the same sheet)

    once it is pasted as sheet 2 in file 3 the code will then a1*a1 + b1*b1 etc throughout the entire sheet and give a value along with the file name.

    this value is needed to be copied and pasted into file 1 and then the whole thing needs to continue throughout the entire folder specified for file 3's

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Grid x Grid SUM problems

    This should be pretty straightforward, particularly the multiplying bit, but without data to work with it's hard to come up with code.

    Can you mock something up?

    PS For the multiplication part store the data from the 2 sources in separate arrays and output them to another array.

    Something like this, untested, code.
    Please Login or Register  to view this content.

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA Grid x Grid SUM problems

    Please Login or Register  to view this content.
    I'm confused by this.
    You have two 53x53 arrays, Alpha and Beta.
    Are you looking to create a third array Gamma, where Gamma(i,j) = Alpha(i,j)^2 + Beta(i,j)^2

    or is the calculation different?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  9. #9
    Registered User
    Join Date
    11-25-2015
    Location
    UK
    MS-Off Ver
    2008
    Posts
    10

    Re: VBA Grid x Grid SUM problems

    i shall make a mock up this evening.

+ 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. 9 box grid
    By Buthaface in forum Excel General
    Replies: 6
    Last Post: 06-01-2020, 03:42 AM
  2. Replies: 1
    Last Post: 10-29-2013, 02:11 AM
  3. Replies: 2
    Last Post: 12-15-2011, 04:14 AM
  4. Looking for a value in a grid
    By Hitch75 in forum Excel General
    Replies: 2
    Last Post: 09-01-2011, 03:59 AM
  5. Grid
    By phil2006 in forum Excel General
    Replies: 2
    Last Post: 06-19-2006, 07:27 AM
  6. I need to convert grid.doc to an Excel Grid.
    By suavejohn in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-01-2005, 02:05 PM
  7. [SOLVED] grid & grid refrences
    By john redmanshaw in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-06-2005, 03:06 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