Prevent formula from changing range when cut and paste data

%3CLINGO-SUB%20id%3D%22lingo-sub-2731038%22%20slang%3D%22en-US%22%3EPrevent%20formula%20from%20changing%20range%20when%20cut%20and%20paste%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2731038%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20workbook%20on%20a%20shared%20drive%20that%20about%2010%20people%20access%20and%20need%20to%20change%20specific%20data.%20In%20the%20workbook%20I%20have%20a%20range%20of%20cells%20representing%20beds%20in%20rooms.%205%20rooms%2C%2020%20beds%20each%2C%20arranged%20in%20a%20column%20with%20space%20between%20each%20group.%20Each%20cell%20represents%20one%20bed%20and%20either%20has%20a%20name%20or%20it%20doesn't.%20At%20the%20end%20of%20the%20range%20is%20a%20formula%20that%20checks%20how%20many%20cells%20have%20names%20and%20outputs%20a%20number%20giving%20a%20total%20number%20of%20occupied%20beds.%20It%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSUM(--ISTEXT(%24C%2463%3A%24C%2482))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20is%2C%20If%20a%20user%20cuts%20a%20name%20from%20one%20room%20and%20pastes%20it%20into%20a%20cell%20of%20another%20room%2C%20the%20formula%20wants%20to%20include%20all%20the%20cells%20from%20the%20point%20of%20origin%20to%20the%20new%20cell.%20I've%20since%20learned%20this%20is%20a%20feature%20and%20desired%20by%20many%20users.%20I%20am%20not%20one%20of%20them.%20My%20own%20knowledge%20of%20excel%20is%20sketchy%20and%20the%20rest%20of%20the%20people%20that%20need%20to%20use%20this%20workbook%20are%20not%20very%20computer%20friendly%20as%20it%20is.%20They%20will%20definitely%20cut%20and%20paste%20no%20matter%20how%20many%20emails%20I%20send%20out%20asking%20to%20copy%20and%20paste.%20Is%20there%20any%20way%20to%20lock%20that%20formula%20and%20make%20this%20workbook%20idiot%20proof%3F%20Or%20is%20there%20a%20different%20way%20to%20write%20that%20formula%20so%20it%20is%20only%20concerned%20with%20whether%20or%20not%20there%20is%20data%20in%20the%20cell%20and%20not%20the%20actual%20data%20itself%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2731038%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2731643%22%20slang%3D%22en-US%22%3ERe%3A%20Prevent%20formula%20from%20changing%20range%20when%20cut%20and%20paste%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2731643%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1149502%22%20target%3D%22_blank%22%3E%40Daktal%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20might%20use%20the%20INDIRECT%20function%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DSUM(--ISTEXT(INDIRECT(%22C63%3AC82%22)))%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eor%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DCOUNTA(INDIRECT(%22C63%3AC82%22))%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2731689%22%20slang%3D%22en-US%22%3ERe%3A%20Prevent%20formula%20from%20changing%20range%20when%20cut%20and%20paste%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2731689%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%20After%20some%20googling%2C%20I%20figured%20the%20INDIRECT%20tag%20was%20going%20to%20be%20the%20key%2C%20but%20I%20couldn't%20for%20the%20life%20of%20me%20get%20the%20syntax%20down%20properly.%20I%20just%20tried%20it%20for%20one%20formula%20and%20it%20worked%20the%20way%20I%20need%20it%20to.%20I'll%20try%20it%20on%20the%20rest%20and%20put%20it%20in%20production%20and%20see%20how%20it%20works.%20But%2C%20it%20looks%20like%20this%20is%20the%20answer.%20Thank%20you%20very%20much.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I have a workbook on a shared drive that about 10 people access and need to change specific data. In the workbook I have a range of cells representing beds in rooms. 5 rooms, 20 beds each, arranged in a column with space between each group. Each cell represents one bed and either has a name or it doesn't. At the end of the range is a formula that checks how many cells have names and outputs a number giving a total number of occupied beds. It looks like this:

 

=SUM(--ISTEXT($C$63:$C$82))

 

The problem is, If a user cuts a name from one room and pastes it into a cell of another room, the formula wants to include all the cells from the point of origin to the new cell. I've since learned this is a feature and desired by many users. I am not one of them. My own knowledge of excel is sketchy and the rest of the people that need to use this workbook are not very computer friendly as it is. They will definitely cut and paste no matter how many emails I send out asking to copy and paste. Is there any way to lock that formula and make this workbook idiot proof? Or is there a different way to write that formula so it is only concerned with whether or not there is data in the cell and not the actual data itself?

3 Replies

@Daktal 

You might use the INDIRECT function:

 

=SUM(--ISTEXT(INDIRECT("C63:C82")))

 

or

 

=COUNTA(INDIRECT("C63:C82"))

@Hans Vogelaar 

 

Thank you! After some googling, I figured the INDIRECT tag was going to be the key, but I couldn't for the life of me get the syntax down properly. I just tried it for one formula and it worked the way I need it to. I'll try it on the rest and put it in production and see how it works. But, it looks like this is the answer. Thank you very much.

@Daktal 

I am with your staff on this!  Of course they will want to use Ctrl/X, Ctrl/V to move a booking from one room to another.  The problem is not the users, it is the fragility of virtually all spreadsheet solutions.

In your case, I would place the entire dataset within a single named range 'beds'.  The data for any given room 'roomNum' is determined by the stride length in rows between rooms (25 say) and the count of beds per room (20).  The room data and occupancy level are then returned by

= OFFSET(Beds,25*(roomNum-1),0,20,1)

= COUNTA(OFFSET(Beds,25*(roomNum-1),0,20,1))

 It doesn't help right now, but something called Lambda functions are now on beta release that will allow you to define a function to return the occupancy for any given room, e.g.

= OCCUPIED("Room2")

= COUNTA(OCCUPIED("Room2"))

In this 'glammed-up' version, the room data and bed count could be returned by XLOOKUP from a pre-defined table that describes the data layout.