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: 19
Default Macro to replace file name in linking formula

In column B I have a linking formula to a specific file. In column A I have
about 200 rows with different file names in each row. I would like to replace
the file name in the linking formula in column B with the file name in Column
A so that then the resulting linking formula in column B would link to the
file name listed in column A. I have the following macro but it only
replaces the first row. I would appreciate help to change the macro so it
continues down column B until it reached a blank cell.

Dim NameOld
Dim NameNew
Dim row

Sub NameReplace()

Range("B6").Select
For row = 6 To 600
NameOld = Cells(4, 1)
NameNew = Cells(row, 1)


Selection.Replace What:=NameOld, Replacement:=NameNew, LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

If Cells(row + 1, 1) = "" Then Exit Sub
Next row
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
macro that adds formula to replace text Lawribird Excel Worksheet Functions 4 July 3rd 09 09:50 PM
Macro to replace file name many times msdrolf Excel Programming 5 October 28th 06 09:09 PM
Macro to evaluate a cell and replace one part of the formula John[_114_] Excel Programming 2 January 19th 06 07:31 PM
How can I replace a formula with its result using a macro? RAP Excel Programming 13 August 1st 05 06:22 AM
macro to export files but not replace an exsisting file name jessica Excel Programming 2 January 7th 04 06:34 AM


All times are GMT +1. The time now is 08:59 AM.

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

About Us

"It's about Microsoft Excel"