+ Reply to Thread
Results 1 to 4 of 4

Use mycolumn name dynamically in formula

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    41

    Use mycolumn name dynamically in formula

    I have an excel report which I am creating Via VBA Macro, with several columns that have calculations on them. The problem is that there are times when my report will have additional or fewer columns. This is causing the fromulas to break since the columns are shifting. So essentially, I never really know where the columns will end up and I don't want to rewrite the formulas every time.

    Say I have the following formula

    =IF(ISBLANK(Q2),0,IF(Y2=""T"",0,1))

    How can I write this to be someting like

    =IF(ISBLANK("Wherever header column" = "ABC"),0,IF("Whever column header is "XYZ" =""T"",0,1))

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,047

    Re: Use mycolumn name dynamically in formula

    Upload example workbook with your input(s) and desired output.
    Make sure to avoid all private informations.
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    10-10-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Use mycolumn name dynamically in formula

    I am unable to upload at this time however here is an example.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    As seen here, the second example has an additional field. It is the same for my report. Sometimes there are additional fields.

    Therefore if I want to do something based on IDNUMBER, I cannot simply say

    If (C2 = "122345") ...

    because the forumla will not work in the second example. I want to instead be able to say

    IF (IDNUMBER = "12345") .... this way it does not matter what column IDNUMBER is in, the formula will always work.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,047

    Re: Use mycolumn name dynamically in formula

    You can make FOR loop.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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