+ Reply to Thread
Results 1 to 7 of 7

change column ref when dragging a count if down

  1. #1
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    137

    change column ref when dragging a count if down

    HI I have a spreadsheet where I want to count yes and no responses to lots of questions. I have created countifs but how do I get them to change the column referenced when I drag them down without doing it manually?

    I have added a test spreadsheet to illustrate what I mean in cells I3 and J3 the count ifs reference column A hwo do I make it so that when I drag them down to the next row - cells I4 and J4 that the formula changes so that it references column B instead without changing it manually?

    Thanks
    J
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-23-2018
    Location
    Iran
    MS-Off Ver
    2016
    Posts
    5

    Re: change column ref when dragging a count if down

    Hi
    you can change reference column/row/cell/... by INDIRECT function.

    Enter the column letter name of each question in column G, then use INDIRECT function as follow:
    1.PNG
    consider the formula in cell I3
    1-
    PHP Code: 
    =COUNTIF(INDIRECT($G3&"2:"&$G3&13,TRUE),"yes"
    2-
    PHP Code: 
    =COUNTIF(INDIRECT("$A2:$A13",TRUE),"yes"
    then INDIRECT function returns a valid reference from a given text string.
    3-
    PHP Code: 
    =COUNTIF($A2:$A13,"yes"
    plz check attached file
    Attached Files Attached Files
    Last edited by RasoolS13; 10-27-2018 at 07:15 AM.

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: change column ref when dragging a count if down

    Please try at I3 drag to J3 and drag down

    =COUNTIF(INDEX($A$2:$E$13,,ROWS(I$3:I3)),I$2)

  4. #4
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    137

    Re: change column ref when dragging a count if down

    Thank you Bo_Ry and RasoolS13 for your responses they will both work however I think the solution from RasoolS13 is better for me as in the source data I have the questions are not in sequential columns so the Bo_ry solution wouldn't work unless I am missing something?

    one question RasoolS13 - how does this work if the source data is on a different tab as I cannot work out how this dictates the source data? I have added another test file to demonstrate what I mean as I have moved the table with the formulas onto sheet 2 but I want to use the source data on sheet 1. Can you help me?
    Attached Files Attached Files

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: change column ref when dragging a count if down

    Then Please try at J3 copy to K8

    =COUNTIF(INDEX(Sheet1!$A$2:$E$13,,MATCH(REPLACE($I3,2,0,"UESTION "),Sheet1!$A$1:$E$1,)),J$2)

    You may change Q1 to other Q# for testing.
    Last edited by Bo_Ry; 10-28-2018 at 10:29 AM.

  6. #6
    Registered User
    Join Date
    10-23-2018
    Location
    Iran
    MS-Off Ver
    2016
    Posts
    5

    Re: change column ref when dragging a count if down

    Quote Originally Posted by moneypennie21 View Post
    one question RasoolS13 - how does this work if the source data is on a different tab as I cannot work out how this dictates the source data? I have added another test file to demonstrate what I mean as I have moved the table with the formulas onto sheet 2 but I want to use the source data on sheet 1. Can you help me?
    Hello

    Just add the name of the worksheet at the beginning of the range, as follows:
    PHP Code: 
    =COUNTIF(INDIRECT("'Sheet1'!"&$H3&"2:"&$H3&13,TRUE),"yes"
    I'm glad that the answer was helpful to you
    Last edited by AliGW; 10-28-2018 at 12:23 PM. Reason: Quotation trimmed.

  7. #7
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    137

    Re: change column ref when dragging a count if down

    Thank you both as both of these solutions work and I actually understand them as well!
    appreciate the help

    J

+ 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. Replies: 3
    Last Post: 12-16-2015, 05:56 PM
  2. [SOLVED] Trying to make column letters change when dragging down.
    By Nitro2481 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-22-2015, 05:14 PM
  3. how to change A:A to B:B while dragging down..
    By meus in forum Excel General
    Replies: 5
    Last Post: 12-12-2014, 01:55 AM
  4. Change the Column When Dragging
    By supdawg1985 in forum Excel General
    Replies: 17
    Last Post: 04-06-2014, 10:33 PM
  5. Change column reference while dragging formula vertically
    By ekatecohn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-18-2013, 07:23 PM
  6. When dragging a formula horizontally, how to change row instead of column?
    By Aderbalito in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-03-2013, 10:44 PM
  7. Replies: 4
    Last Post: 02-25-2013, 05:27 PM

Tags for this Thread

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