OFFSET WIDTH VALUE PROBLEM

drluke

Active Member
Joined
Apr 17, 2014
Messages
314
Office Version
  1. 365
Platform
  1. Windows
I am trying the sum col AP:BA based on the period number in AN1. The sum formula needs to be dynamic as the period number changes. My problem is that my width argument that takes the first 2 characters from AN1 (which is in a date format) = 44 instead of 08. Is there any way to overcome this problem without having to change the format/type of AN1. If I change the format of AN1 it will cause formulas elsewhere in the spreadsheet to fail. Any advice greatly appreciated.


Macro FAR2 (version 1).xlsb.xlsm
ANAOAPAQARASATAUAVAWAXAYAZBA
108/2123451020304050607080
2374
Details
Cell Formulas
RangeFormula
AN1AN1=C4
AP2AP2=SUM(OFFSET(AP1,0,0,1,LEFT(AN1,2)),0)
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi DrLuke,

1 August 2021 was the 44,409th day since 1 Jan 1900 (as Excel holds dates as integer days since that date) so you're seeing the 44.

Assuming your date is shown as mm/yy (as we don't see C4 so can't see its origin) then try

Excel Formula:
=SUM(OFFSET(AP1,0,0,1,MONTH(AN1)),0)
 
Upvote 0
Solution
MAybe also....
Excel Formula:
=SUM(OFFSET(AP1,0,0,1,DAY(AN1)),0)
 
Upvote 0
Just a consideration, how many of these formulas are you planning on using ?
Offset is a volatile function and while using a few of them will be of little concern if you are planning on applying it to thousands of rows it may impact your spreadsheet performance.

In which case you could consider using index as per the below. Just set the end of the index range wider than you are ever going to need.

Book2
AMANAOAPAQARASATAUAVAWAXAYAZBABB
121/08/202123451020304050607080
2114
3
Sheet1
Cell Formulas
RangeFormula
AP2AP2=SUM(AP1:INDEX(AP1:BZ1,0,MONTH(AN1)))
 
Upvote 0

Forum statistics

Threads
1,214,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top