+ Reply to Thread
Results 1 to 9 of 9

vba script to calculate data across multiple columns

  1. #1
    Registered User
    Join Date
    06-27-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    2

    vba script to calculate data across multiple columns

    Hi all,

    i have a rather large data sheet that i need to perform a calculation on by a fixed amount per column

    i have around 300 columns of data, with around 600 rows, i have written this script which performs the calculation on a single column of data, but need to expand it to cover all columns of data

    Please Login or Register  to view this content.

    here is a sample of my dataset

    4.7239 4.7239 4.7239 2.3021
    COmpany1 Company2 Company3 Company4
    -203222 300000 2000000 -4443322
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    0 0 0 0
    Last edited by pchappo; 07-14-2017 at 02:39 AM. Reason: added tags

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: vba script to calculate data across multiple columns

    Hi pchappo

    Welcome to the forum....
    In future please view the forum rules before posting. Your post does not comply with rule #3.
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window.
    Can give this a go...

    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    06-27-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    2

    Re: vba script to calculate data across multiple columns

    Hi Sintek,

    many thanks - have ammended my first post to put the code into code..

    One issue with this is i need the divisor to be 'fixed' at row 1 of the column


    Please Login or Register  to view this content.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: vba script to calculate data across multiple columns

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: vba script to calculate data across multiple columns

    Hello
    Can you post sample of your workbook?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,530

    Re: vba script to calculate data across multiple columns

    300x600 = 180000 calculations.

    My advice would be to load entire range into array, perform calculations in memory and write array back to worksheet.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: vba script to calculate data across multiple columns

    @ bakerman2
    So this stores calculated value in array...How to populate range with arr values?
    Please Login or Register  to view this content.
    Edited...Nope Not storing used range!!!
    Last edited by Sintek; 07-14-2017 at 04:05 AM.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,530

    Re: vba script to calculate data across multiple columns

    something like this.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: vba script to calculate data across multiple columns

    @ bakerman2...
    Why does this only store the first column values in the code in post 7?
    Please Login or Register  to view this content.

    Edited...How bout this....
    Please Login or Register  to view this content.
    Last edited by Sintek; 07-14-2017 at 07:56 AM. Reason: Code code working....

+ 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. [SOLVED] VBA script to open multiple links from a couple of columns in a spreadsheet
    By mss90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2016, 02:04 AM
  2. Replies: 7
    Last Post: 02-19-2016, 03:50 PM
  3. [SOLVED] Calculate NETWORKDAYS from multiple columns and return NA if columns not populated yet
    By Cdavies in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-16-2014, 10:51 AM
  4. Calculate period between multiple dates _VBA script
    By raw_geek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2014, 08:03 AM
  5. Combine multiple cells in columns - Concat with variable spacing using VBA Script
    By AMC_CO in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-13-2013, 03:57 PM
  6. Macro/Script for Moving Groups of Data in to Separate Columns
    By JustinSxcel in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 07-05-2012, 01:56 AM
  7. script to split 4 columns of data into 12
    By madunlop in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-24-2009, 09:39 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