LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Replacing Formulae With Values.....Continuation

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing Values in a Spreadsheet In need of enlightenment[_2_] Excel Discussion (Misc queries) 0 March 28th 07 02:44 AM
Replacing Values in a Spreadsheet Joel Excel Discussion (Misc queries) 0 March 27th 07 11:44 PM
Replacing Linked Cell Values w/ Current Values TomCat Excel Worksheet Functions 6 April 10th 06 12:20 PM
Another Question Concerning Replacing Formulae With Values ! [email protected] Excel Programming 15 June 29th 05 04:03 AM
Replacing links with values John[_68_] Excel Programming 1 December 15th 03 05:47 PM


All times are GMT +1. The time now is 05:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"