Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm posting the complete macro code in a hope somebody can spot
something that may be wrong. For those of you that have not been keeping track of my previous post over the last few days; I am copying 2 sheets from one file into a new file and then removing all the formulae by replacing them with the cell value. I am doing this to remove links that I have present. The problem I have though is that it errors out during the last usedrange.formula=usedrange.value. If I have copied one sheet it fails on that one. If I have copied 2 sheets, then it does the first one but fails on the second!. The Runtime error that pops up happens on the last run through of the '*'d line with the error message..... Mehtod 'Formula' of object 'Range' failed .......Here's my code.... Option Explicit Sub Actual1() Dim FName As String Dim i As Integer Dim s, w ReDim MyResults(1 To 100) Dim iArea As Range '''''''''''''''''''''''''' ' Selects The Chart File ' '''''''''''''''''''''''''' For Each w In Workbooks If InStr(w.Name, "Charts") Then FName = w.Name Exit For End If Next w If FName = "" Then MsgBox ("You Need A Chart File Open.") GoTo End1: Else Workbooks(FName).Activate End If '''''''''''''''''''''''''''''''' ' These Are The Sheets To Copy ' '''''''''''''''''''''''''''''''' MyResults(1) = "A3RH" MyResults(2) = "C6LH" ReDim Preserve MyResults(1 To 2) Workbooks(FName).Activate Sheets(MyResults(UBound(MyResults))).Activate Sheets(MyResults).Copy Worksheets.Add after:=Worksheets(Worksheets.Count) ChDrive "I" ChDir "I:\Data\Temp\Copy Chart" ActiveWorkbook.SaveAs Filename:="Copy Chart.xls" Application.CutCopyMode = False '''''''''''''''''''''''''''''''''''''''' ' Removes All Formulae And Hence Links ' '''''''''''''''''''''''''''''''''''''''' For Each s In ActiveWorkbook.Sheets s.Activate s.Unprotect Cells.Select Selection.MergeCells = False Columns("AZ").ColumnWidth = 17.75 Range("AX1").Select s.UsedRange.Formula = s.UsedRange.Value s.Protect Next s End1: End Sub .......Any ideas? And thanks to those guys that have kept posting to my previous thread over the past few days. |
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 | |||
Another Question Concerning Replacing Formulae With Values ! | Excel Programming | |||
Replacing links with values | Excel Programming |