LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Replacing formulas in Excel- correction

Option Explicit

Sub test()
Dim testrange()
Dim fillrange()
Dim theusedrange As Range
Dim firstrow As Integer, lastrow As Integer, firstcol As Integer,
lastcol As Integer
Dim i As Integer, j As Integer
Dim wks As Worksheet
Application.ScreenUpdating = False
For Each wks In ActiveWorkbook.Worksheets
wks.Activate
firstrow = ActiveSheet.UsedRange.Row
lastrow = ActiveSheet.UsedRange.Rows.Count + firstrow - 1
firstcol = ActiveSheet.UsedRange.Column
lastcol = ActiveSheet.UsedRange.Columns.Count + firstcol - 1
Set theusedrange = Range(Cells(firstrow, firstcol),
Cells(lastrow, lastcol))
ReDim testrange(firstrow To lastrow, firstcol To lastcol)
ReDim fillrange(firstrow To lastrow, firstcol To lastcol)
For i = firstrow To lastrow
For j = firstcol To lastcol
fillrange(i, j) = Cells(i, j).Formula
testrange(i, j) = Cells(i, j).Value
If Left(fillrange(i, j), 5) = "=SUM(" Then
fillrange(i, j) = testrange(i, j)
End If
Next j
Next i
theusedrange.Formula = fillrange
Set theusedrange = Nothing
Next wks
Application.ScreenUpdating = True
End Sub
 
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
excel replacing my text Dutchess46514 Excel Worksheet Functions 3 September 12th 09 05:43 PM
Excel - replacing Text in workbooks Frank Excel Worksheet Functions 1 August 7th 07 12:57 AM
Replacing formulas with its value Marcus A Excel Worksheet Functions 4 September 21st 06 06:24 PM
replacing just the sheet names within formulas Jeanne Criez Excel Worksheet Functions 1 January 4th 05 06:27 PM
Replacing a number with a description in Excel Steinbart Excel Worksheet Functions 2 December 7th 04 09:43 PM


All times are GMT +1. The time now is 03:42 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"