+ Reply to Thread
Results 1 to 9 of 9

vba script to calculate data across multiple columns

Hybrid View

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

    Re: vba script to calculate data across multiple columns

    @ bakerman2
    So this stores calculated value in array...How to populate range with arr values?
    Option Explicit
    
    Sub calculate()
    Dim CalcArr As Variant
    Dim lRow, lCol, i As Long
    Dim rng, cell As Range
    lRow = Cells(Rows.Count, "D").End(xlUp).Row
    lCol = Cells(3, Columns.Count).End(xlToLeft).Column
    With Sheet1
        i = 1
        Set rng = .Range(.Cells(3, 4), .Cells(lRow, lCol))
        CalcArr = rng.value
        For i = LBound(CalcArr) To UBound(CalcArr)
            CalcArr(i, 1) = CalcArr(i, 1) / .Range("D1")
        Next i
    End With
    rng.value = CalcArr
    End Sub
    Edited...Nope Not storing used range!!!
    Last edited by Sintek; 07-14-2017 at 04:05 AM.
    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!!!

+ 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