+ Reply to Thread
Results 1 to 5 of 5

Using VBA to add new calculated columns

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Using VBA to add new calculated columns

    Hi. I'm struggling to write a code that will produce the result appears in the attached file. Recording macros brought me so far (not even close). Thanks:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Using VBA to add new calculated columns

    Hi, GIS2013,

    maybe like this if you have just the raw data on the sheet:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Using VBA to add new calculated columns

    Hi HaHoBe,
    Thanks, and two questions:
    -If my real DataBase contains much more columns (and as a result I'll need much more new columns to insert)?
    -How do I decode this: Range("C3:C" & Range("A" & Rows.Count).End(xlUp).Row)? It looks like a nested range object? could you simplify it a bit for me?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Using VBA to add new calculated columns

    Hi, GIS2013,

    I donŽknow about the requirements in the "real" Database but only about the sample posted here. If there are more columns and you need more single columns you could use
    Please Login or Register  to view this content.
    Here you would need to enter the ranges for the columns where you want to insert an empty column, these are inserted in one go whereas my code inserted them one at a time (and thus had different ranges indicated).

    Please Login or Register  to view this content.
    You need to know how far the formulas should go. I assumed Column A to be filled throughout and take the row number from there to fill the formulas. Please mind that you would to alter the formula ranges as well as they refer to the situation in the sample.

    HTH,
    Holger

  5. #5
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Using VBA to add new calculated columns

    All clear now, thanks again.

+ 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. Adding an IF formula to a calculated field - columns with common names
    By milleniummanp7 in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 06-21-2013, 01:16 PM
  2. Locking columns based on calculated cell values in columns across a sheet.
    By andyr826208 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-04-2012, 05:17 AM
  3. Copy and paste a string of cells into 41 calculated rows and columns
    By rclark430 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2011, 08:15 PM
  4. Replies: 2
    Last Post: 03-06-2009, 11:49 AM
  5. [SOLVED] pivot table formulas for calculated field or calculated item
    By Vicky in forum Excel General
    Replies: 3
    Last Post: 06-06-2006, 12:10 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