Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash desktop dns driver drivers error ethernet excel freeze gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard network printer problem ram registry repair router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Fixed cell reference

Reply  
Thread Tools
tbeatham's Avatar
Member with 72 posts.
 
Join Date: Feb 2003
19-Nov-2009, 12:28 PM #1
Fixed cell reference
Can anyone tell me how I can fix a cell reference in Excel so that the formula doesn't change when I move things about. The dollar sign does not seem to work.

I have a spreadsheet that has 2 workbooks, the first work book has a number of coumns across the page i.e. 10 weeks which is being used to give a 10 week average. I then run a macro each week that deletes the first column, and moves all the remaining columns along one so that I can then enter the details in the end column for the most recent weeks information. It is this end column I want to refer to in the other workbook to pick up a figure and use in another formula but unfotrunately every time I run the macro the referencing in the other workbook changes to pick up the original figure. i.e. the column reference moves with the running of the macro.

I have tried using the dollar sign to fix the cell refrence but this is not having any effect.

Would be really grateful if someone could help me as this will save me a whole load of work having to re-key information.

Cheers
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
19-Nov-2009, 12:45 PM #2
Can you post a sample - remove personal/sensitive data before doing so.
tbeatham's Avatar
Member with 72 posts.
 
Join Date: Feb 2003
19-Nov-2009, 01:05 PM #3
Excel Spreadsheet
Please see the attached spreadsheet for information.
Attached Files
File Type: xls 48 Hour Working Summary.xls (194.0 KB, 40 views)
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
20-Nov-2009, 12:25 PM #4
tbeatham, it seems to me there's a lot of redundant stuff in your macro - which is often the case with recording macros.

Case in hand, there's a lot of recorded actions of scrolling the screen where this is unnessessary, so have taken these out in the code and have don;e some general tidying up.

Also, there have been areas in the code where you have copied contents to the end week only to clear their contents - I have deleted these also.

The code has been whittled down a bit. I have included a quick way of solving the problem with your moving references in the 'All' tab, which is to replace the '=' before doing the macro and then to put it back in afterwards.

As usual, please test the code on sample data before running on mission critical stuff.
Code:
Sub Update()
'
Set wSH = Sheets("Wages (2)")
Set aSH = Sheets("All (2)")

wSH.Cells.Replace What:="=", Replacement:="xxx"

    
        aSH.Range("F5:U66").Cut Range("E5")
        aSH.Range("F71:U107").Cut Range("E71")
        aSH.Range("F112:U173").Cut Range("E112")
    
        aSH.Range("F178:U239").Cut Range("E178")
        aSH.Range("F244:U300").Cut Range("E244")
    
        aSH.Range("F307:U342").Cut Range("E307")
    
wSH.Cells.Replace What:="xxx", Replacement:="="
End Sub
tbeatham's Avatar
Member with 72 posts.
 
Join Date: Feb 2003
23-Nov-2009, 08:32 AM #5
Thanks for the update on my spreadsheet and your help with my problem but I am a little lost as to what you have given me. You have said that you have tidied my code up but I have no copy of the spreadsheet so see what you have done and you have provided me with a macro routine but I am not sure what I am supposed to do with this. Do I stick it at the end of my macro or at the beginnning.
Really would appreciate some more guidance thanks.
Cheers,
Tim
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
23-Nov-2009, 08:48 AM #6
Quote:
Originally Posted by tbeatham View Post
Thanks for the update on my spreadsheet and your help with my problem but I am a little lost as to what you have given me. You have said that you have tidied my code up but I have no copy of the spreadsheet so see what you have done and you have provided me with a macro routine but I am not sure what I am supposed to do with this. Do I stick it at the end of my macro or at the beginnning.
Really would appreciate some more guidance thanks.
Cheers,
Tim

Sorry tim, I should have been clearer. The routine is to replace the one you have in module6. You can copy/paste it in any of the modules you have when you open up the VB editor.
turbodante's Avatar
Senior Member with 744 posts.
 
Join Date: Dec 2008
Location: GMT UK
23-Nov-2009, 08:49 AM #7
Also, you may want to alter the following lines in the code to reflect the names of your sheets...

Code:
Set wSH = Sheets("Wages (2)")
Set aSH = Sheets("All (2)")
to

Code:
Set wSH = Sheets("Wages")
Set aSH = Sheets("All")
tbeatham's Avatar
Member with 72 posts.
 
Join Date: Feb 2003
23-Nov-2009, 08:59 AM #8
Thanks for the speedy reply and I amnaged to figure out the details but have tried the macro and unfortunately it does not seem to work correctly for the weeks as it just removes the end column and moves the data along each week without putting a new blank column on the end. The macro does appear to hold the cell referencing on the wages worksheet.
The columns are supposed to basically drop of the first week in the series and then add a new column to have data entered for the latest week so that effectively you get a 17 week moving average calculated. This is probably why I copied the previous weeks data across and then blanked out the figures.
I'll have a work on it as I think it won't take much to complete now.
Thanks again for your help with this.
Reagrds,
tim
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:07 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.