Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I know, I know...but yes, another one !
I've seen various methods for this but all of them give me a RunTime Error. If I select the cells with a formulae in and use a For/Next loop to change each of those cells individually then it does work BUT it takes about 5 minutes to do it. Every thing else fails. I've tried.... 1.) .UsedRange.Value = .UsedRange.Value 2.) .UsedRange.Formula = .UsedRange.Value 3.) Selection.Copy Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False 4.) Set rng = Columns("B:BM").Cells '.SpecialCells(xlCellTypeFormulas) rng.Value = rng.Value I have a lot of cells with formulae in a lot of cells with links in. It's the links I really need to remove, the internal formalue can stay if need be. Can anybody suggest any alternatives that I have not tried yet. These cells that I want to remove the links/formulae in are dotted around the worksheet and are not therefore continuously next to each other. Thanks for any suggestions you can give. Donna |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Good afternoon Try using the For ... Each ... Next structure thus: Sub Change() For Each usrcell In Selection usrcell.Formula = usrcell.Value Next usrcell End Sub Just remember to highlight the required range before running the macro. HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=381918 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
All the methods (Except #4) you show should work unless you have merged
cells in your worksheet. -- Regards, Tom Ogilvy wrote in message oups.com... I know, I know...but yes, another one ! I've seen various methods for this but all of them give me a RunTime Error. If I select the cells with a formulae in and use a For/Next loop to change each of those cells individually then it does work BUT it takes about 5 minutes to do it. Every thing else fails. I've tried.... 1.) .UsedRange.Value = .UsedRange.Value 2.) .UsedRange.Formula = .UsedRange.Value 3.) Selection.Copy Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False 4.) Set rng = Columns("B:BM").Cells '.SpecialCells(xlCellTypeFormulas) rng.Value = rng.Value I have a lot of cells with formulae in a lot of cells with links in. It's the links I really need to remove, the internal formalue can stay if need be. Can anybody suggest any alternatives that I have not tried yet. These cells that I want to remove the links/formulae in are dotted around the worksheet and are not therefore continuously next to each other. Thanks for any suggestions you can give. Donna |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Folkes, thanks for your replys, but Iam still having problems.
KeepITcool.......I can not find any reference to 'BreakLinks' even using the VBE Object browser. LinkSources is there but it won't allow'BreakLinks'. Is it in a seperate library I won't have referenced? Dominicb.......For Each works but is too slow for me (~5 mins), hence trying the other methods. Tom........I have removed any mergedcells I had and tried the ..usedrange=.usedrange again but it still error out. I have tried deleting all my charts etc to try and eliminate what may be the problem, but it still errors out with the error... Method 'Value' of bject 'Range' failed ...... What does the 'UsedRange' select ? I have cells with values, formulae and links. I also have charts which reference data on it's own sheet and have a couple of OptionButtons generated from the Contol Toolbox toolbar. As far as I can see, the 'UsedRange.select' is only selecting cells (which is whatI want)...but is it? What I don't understand is ....... For Each icell In Selection.SpecialCells(xlCellTypeFormulas, 23) ' icell.Value = icell.Value Next icell ......works (but very slow) |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
extension to last post. I pressed Post too early!
but this doesn't work... Cells.SpecialCells(xlCellTypeFormulas).Select With Selection .Value = .Value End With ..... Can anybody tell my why. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Depending on how the formulas are spreadout this might be a little quicker:
Option Explicit Sub testme() Dim myRng As Range Dim myArea As Range Set myRng = Nothing On Error Resume Next Set myRng = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas) On Error GoTo 0 If myRng Is Nothing Then 'no formulas Else For Each myArea In myRng.Areas With myArea .Value = .Value End With Next myArea End If End Sub I used the Activesheet and converted all the cells--but you could limit the range. But if you want all the formulas converted to values: with activesheet.usedrange .value = .value end with wrote: extension to last post. I pressed Post too early! but this doesn't work... Cells.SpecialCells(xlCellTypeFormulas).Select With Selection .Value = .Value End With .... Can anybody tell my why. -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm the only one that gave the "correct" reply.
but no reaction from OP. the original question included: I have a lot of cells with formulae in a lot of cells with links in. It's the links I really need to remove, the internal formalue can stay if need be. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Dave Peterson wrote : Depending on how the formulas are spreadout this might be a little quicker: Option Explicit Sub testme() Dim myRng As Range Dim myArea As Range Set myRng = Nothing On Error Resume Next Set myRng = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas) On Error GoTo 0 If myRng Is Nothing Then 'no formulas Else For Each myArea In myRng.Areas With myArea .Value = .Value End With Next myArea End If End Sub I used the Activesheet and converted all the cells--but you could limit the range. But if you want all the formulas converted to values: with activesheet.usedrange .value = .value end with wrote: extension to last post. I pressed Post too early! but this doesn't work... Cells.SpecialCells(xlCellTypeFormulas).Select With Selection .Value = .Value End With .... Can anybody tell my why. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave,
I have used your method. Below is the code ..... For Each iArea In Cells.SpecialCells(xlCellTypeFormulas).Areas iArea.Select On Error GoTo ErrHand: iArea.Value = iArea.Value Next iArea ErrHand: On Error GoTo 0 Resume Next .......I have stepped through and it selects and changes all the areas until the last area where it jumps to the error handling routine and from there jumps back to Next iArea as you'd expect but from there jumps back to ErrHand, where it errors out with an error message I can't remember (useful eh !)....something along the lines of ' Erroring with no Error'. I will run it again and post the error message butI have to logout before I do this! All the links have disappeared (which is what I am after) (Edit - Links is greyed out) so it has obviously done all the necessay cells but why does it error out while doing the last iArea ? The last area contains a load of formuale that results in the cell being '#N/A' but the previous 2 areas also did and it didn't go to the ErrHand: and didn;t error out while changing those areas. I don't think the '#N/A' s are the problem but I mention it incase it is. Any ideas ? |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This code does what I want, but when I press save I get a memory
couldnot be read error so there definately must be a problem somewhere with the .value=.value line. I noticed that it only errored on the last iArea even though it had already changed some similar areas, so I added another sheet into the loop(Was 1 sheet, now 2 sheets). Now it will jump into the ErrHand line on the last iArea of the last sheet (it will run through the first sheet without jumping into the ErrHand !)..... For Each s In ActiveWorkbook.Sheets s.Activate s.Unprotect Cells.Select Selection.MergeCells = False Columns("AZ").ColumnWidth = 17.75 For Each iArea In Cells.SpecialCells _(xlCellTypeFormulas).Areas iArea.Select On Error GoTo ErrHand: iArea.Value = iArea.Value On Error GoTo 0 Next iArea Range("AX1").Select s.Protect Next s GoTo End1: ErrHand: Resume Next End1: ......Why should it be erroring out on the last iArea it meets. And why when I add a sheet does it then complete the sheet that it errored on before but then error on the last iArea of that new sheet ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Replacing Values in a Spreadsheet | Excel Discussion (Misc queries) | |||
Replacing Values in a Spreadsheet | Excel Discussion (Misc queries) | |||
Replacing Linked Cell Values w/ Current Values | Excel Worksheet Functions | |||
Replacing zero values with dashes | Excel Discussion (Misc queries) | |||
Replacing links with values | Excel Programming |