+ Reply to Thread
Results 1 to 3 of 3

Smart way to reference cells from certain column on same row

  1. #1
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,841

    Smart way to reference cells from certain column on same row

    I have a "current row" and I want to do calculations and manipulations of values from certain columns on that same row.
    I either use Excel Table feature or name columns. I use the intersect command in VBA to reference cells on the same row from different columns. While this works and is robust it is also cumbersome and makes for a messy code.
    I'm about as comfortable using offset and a fixed number as I am playing Russian roulette because I know columns will be rearranged/added/deleted every now and then.

    In this thread I use the space operator in a formula (sorry you have to download the workbook). https://www.excelforum.com/excel-gen...x-matches.html

    Is there a way to use the space operator in VBA via the evaluate command or something?
    Any hint, clue, tip or experience about this type of problem is welcome.

    PS. Yes there is a reason (multiple actually) that I don't just use formulas in the worksheet.
    Attached Files Attached Files
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Smart way to reference cells from certain column on same row

    I'd be inclined to use Application.Match to determine the column and then use something like Cells(c.Row, lColumn) to refer to the cell, where lColumn is the column number (from the Match). You would only need to do the Match at the beginning of the process (before the loop starts).

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,841

    Re: Smart way to reference cells from certain column on same row

    To be honest I already use the named columns to get a difference in column numbers and then use that number in offset.
    Using cells is a bit slicker, I'll try that, thanks!

+ 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. Reference a column by table column name in Cells function
    By schristensen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-16-2016, 02:24 PM
  2. Replies: 1
    Last Post: 07-08-2015, 02:53 AM
  3. "Smart" Column Reference Numbers
    By the.ronin in forum Excel General
    Replies: 0
    Last Post: 05-29-2012, 12:12 PM
  4. Replies: 1
    Last Post: 07-12-2006, 08:10 AM
  5. [SOLVED] How do I stop smart tags obscuring the cells on my worksheet?
    By Polgara in forum Excel General
    Replies: 1
    Last Post: 04-10-2006, 03:25 AM
  6. [SOLVED] Adding Smart Tags to an unrecognized cell reference
    By SauveC in forum Excel General
    Replies: 3
    Last Post: 02-11-2005, 10: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