Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2014, 10:43 AM
skoz55 skoz55 is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 64bit
Novice
Locking A Cell Reference Regardless
 
Join Date: Jan 2009
Posts: 20
skoz55 is on a distinguished road
Default Locking A Cell Reference Regardless

I would like to lock reference to cells (not the value in the cell) and prevent that from changing regardless if I insert, delete, or move the column/row/value.

Example (see attached spreadsheet)
B3 calculates the sum of the last four months of sales, C3:F3 (Jan - April). Next month I will enter May's sales and want B3 to still sum up the last four months (so Jan will not be part of the calculation but the new May will).

At this point, when I insert a new column before C to post the May sales data, B3 changes reference to D3:G3.



Is there a way to lock the reference to C3:F3 regardless of what happens to those cells?

Thanks.
Attached Files
File Type: xls a.xls (64.0 KB, 9 views)
Reply With Quote
  #2  
Old 05-13-2014, 12:51 PM
BobBridges's Avatar
BobBridges BobBridges is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

I think the OFFSET function will do it for you. Yep, that's what you want. Try this:
Code:
=SUM(OFFSET(B3,0,1):OFFSET(B3,0,4))
The OFFSET function starts with a given cell (B3, in this case, which is the very cell the function is in), then adds a certain number of rows and columns to it. I specified 0 rows and between 1 and 4 columns.

You can just as easily specify a different starting cell and then correspondingly different row and column offsets; this just seemed intuitively obvious to me.
Reply With Quote
  #3  
Old 05-14-2014, 02:46 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,780
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

An alternative
Code:
=SUM(INDIRECT("C3:F3"))
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #4  
Old 05-14-2014, 08:06 AM
BobBridges's Avatar
BobBridges BobBridges is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Ah, of course. I used to use INDIRECT a lot, and then decided that for many situations I should use OFFSET instead. But for this case I think Peco's solution is better: It's more intuitively obvious to the eye.
Reply With Quote
  #5  
Old 05-14-2014, 11:59 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,780
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

In fact OFFSET and INDIRECT being voltaile functions, I don't like to use them.
In this case the use of INDEX might be better but I haven't got XL on my Linux machine to test it
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #6  
Old 05-14-2014, 10:13 PM
skoz55 skoz55 is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 64bit
Novice
Locking A Cell Reference Regardless
 
Join Date: Jan 2009
Posts: 20
skoz55 is on a distinguished road
Default

Thanks guys. It appears the INDIRECT function is best suited for this. Most of my reference are nested if statements, thus the INDEX function just makes the formula longer and more confusing.
Reply With Quote
  #7  
Old 05-15-2014, 09:23 AM
BobBridges's Avatar
BobBridges BobBridges is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Wait—OFFSET and INDIRECT are volatile? Why would that be? Well, I guess I can see why INDIRECT would be, though I never thought about it before. But OFFSET shouldn't have to be volatile. How do you know? Have you read it somewhere, or what?
Reply With Quote
  #8  
Old 05-16-2014, 06:19 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,780
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Bob, perhaps have a look at this page
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #9  
Old 05-16-2014, 09:15 AM
BobBridges's Avatar
BobBridges BobBridges is offline Locking A Cell Reference Regardless Windows 7 64bit Locking A Cell Reference Regardless Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Now that is good information! Thanks, Peco. I think I want to bookmark it, but I don't have a handy category for it. I'll figure something out.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Locking A Cell Reference Regardless Keeping an absolute reference in a cell bremen22 Excel 7 01-16-2014 11:06 AM
Locking A Cell Reference Regardless How to reference a cell value Jmoney2290 Excel 1 11-06-2013 09:39 PM
Locking A Cell Reference Regardless Reference number and cross reference for equation numbers to match the thesis format wmac Word 1 05-14-2013 08:54 PM
locking out word joe Word 0 11-19-2009 02:09 AM
How do I reference a merged cell in a multi column & row table in MS Word ('03')? jihanemo Word Tables 0 03-18-2009 08:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:10 AM.


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