Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-08-2013, 08:06 PM
dlowrey dlowrey is offline Syntax to use  OFFSET() in a cell formula? Windows 7 64bit Syntax to use  OFFSET() in a cell formula? Office 2010 32bit
Novice
Syntax to use  OFFSET() in a cell formula?
 
Join Date: Feb 2012
Posts: 29
dlowrey is on a distinguished road
Default Syntax to use OFFSET() in a cell formula?

Can you help me correct the syntax?

I am using CountIf() to count occurrences of a string in a range.
=COUNTIF($A$4:$AB$54,TEXT(AD5,"")) <--this works fine.

Now I want to add another condition, whether the cell, 3 cells to the right on the same row, has the string value of "x". I am having trouble using Offset() to make this work.

This formula is broken.
=COUNTIF($A$4:$AB$54,TEXT(AD5,""+TEXT(OFFSET AD5,-3,"x")))

Thank you in advance for help.

-DL
Reply With Quote
  #2  
Old 07-08-2013, 10:28 PM
dlowrey dlowrey is offline Syntax to use  OFFSET() in a cell formula? Windows 7 64bit Syntax to use  OFFSET() in a cell formula? Office 2010 32bit
Novice
Syntax to use  OFFSET() in a cell formula?
 
Join Date: Feb 2012
Posts: 29
dlowrey is on a distinguished road
Default OFFSET() inside of COUNTIF()

Update, I am a little closer. This formula doesn't throw an error, but also doesn't return a correct count.
=COUNTIF($A$4:$AB$54,TEXT(AD5,""+TEXT(OFFSET(Selec tion,0,1,1,1),"x")))

I think the problem is Excel needs to know which cell from which to offset. "Selection" does not seem to do the trick. So, maybe I need to know how to detect each cell as CountIF() iterates through the range. Am I on the right track?

Thanks
Reply With Quote
  #3  
Old 07-09-2013, 06:19 AM
CGM3 CGM3 is offline Syntax to use  OFFSET() in a cell formula? Windows XP Syntax to use  OFFSET() in a cell formula? Office 2007
Advanced Beginner
 
Join Date: Oct 2009
Posts: 38
CGM3 is on a distinguished road
Default

Here's a reference I put together for using OFFSET():

Code:
OFFSET($A$1,ROW()-1,COLUMN()-1) : the 'current' cell (never use it, would probably cause a circular reference)
OFFSET($A$1,ROW()-1,COLUMN()-2) : the cell to the left of the 'current' cell
OFFSET($A$1,ROW()-1,COLUMN()-3) : the cell two columns to the left of the 'current' cell
 OFFSET($A$1,ROW()-1,COLUMN())   : the cell to the right of the 'current' cell
OFFSET($A$1,ROW()-1,COLUMN()+1) : the cell two columns to the right of the 'current' cell
OFFSET($A$1,ROW(),COLUMN()-1)   : the cell beneath the 'current' cell
OFFSET($A$1,ROW()-2,COLUMN()-1) : the cell above the 'current' cell
And here's the definition from Excel help:
Code:
OFFSET(reference, rows, cols, [height], [width]) 
 
The OFFSET function syntax has the following arguments:
 
Reference  Required. The reference from which you want to base the offset. Reference must refer to a cell or range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value.
Rows       Required. The number of rows, up or down, that you want the upper-left cell to refer to. Using 5 as the rows argument specifies that the upper-left cell in the reference is five rows below reference. Rows can be positive (which means below the starting reference) or negative (which means above the starting reference).
Cols       Required. The number of columns, to the left or right, that you want the upper-left cell of the result to refer to. Using 5 as the cols argument specifies that the upper-left cell in the reference is five columns to the right of reference. Cols can be positive (which means to the right of the starting reference) or negative (which means to the left of the starting reference).
Height     Optional. The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
Width      Optional. The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
 
Remarks
If rows and cols offset reference over the edge of the worksheet, OFFSET returns the #REF! error value.
If height or width is omitted, it is assumed to be the same height or width as reference.
OFFSET doesn't actually move any cells or change the selection; it just returns a reference. OFFSET can be used with any function expecting a reference argument. For example, the formula SUM(OFFSET(C2,1,2,3,1)) calculates the total value of a 3-row by 1-column range that is 1 row below and 2 columns to the right of cell C2.
Reply With Quote
  #4  
Old 07-09-2013, 09:15 AM
dlowrey dlowrey is offline Syntax to use  OFFSET() in a cell formula? Windows 7 64bit Syntax to use  OFFSET() in a cell formula? Office 2010 32bit
Novice
Syntax to use  OFFSET() in a cell formula?
 
Join Date: Feb 2012
Posts: 29
dlowrey is on a distinguished road
Default Offset()

CGM3, thanks for the reply.

I think your work is a help. But I am confused by the absolute cell reference $A$1.

CountIf() is running through a range of multi columnar data. It might find a matching value in E5, or G7 or AB15, In this case the count would be 3.

But we really don't want it to count unless the value in a cell 3 columns to the right is "x". I don't see how I can use an absolute cell reference, because we don't know where CountIf() will find a match.

Thanks again for the example.

-DL
Reply With Quote
Reply

Tags
countif(), offset()

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax to use  OFFSET() in a cell formula? formula help with total in same cell jterr Excel 14 02-25-2013 05:43 PM
Change formula cell range based on cell value Scoth Excel 4 10-25-2012 07:51 AM
Syntax to use  OFFSET() in a cell formula? Keep cell in formula constant jprt68 Excel 1 06-26-2012 08:31 AM
Syntax to use  OFFSET() in a cell formula? Vlookup, offset, match & countif jujuwillis Excel 2 10-15-2011 11:06 AM
Syntax to use  OFFSET() in a cell formula? Protect formula in cell? markg2 Excel 4 05-24-2010 11:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft