Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Replace script

Hi everyboby
I'm having a problem with a short replace macro i'm trying to write in
excel

I have two sheets on the same workbook one called "colour full" and
one called "colour"
Sheet "colour" contains a table with colour code (range name
"ColourID") and the coresponding
description. Sheet "colour full" contains a column of colour code
which i would like to replace with the description.

my problem seems to be the
For Each Cell In Worksheets("colour").Range("ColourID")
line as the script only replaces the first row on the sheet "colour",
not then moving down to the next row and repeating the replace
function untill it has run to the end of the "ColourID" range.

No doubt it is a stupid/obvious error I have made but I'm new to this
and any help would be much apreciated as i have a lot of these replace
tasks to do.


Sub colour()
'
' colour Macro
'
' Keyboard Shortcut: Ctrl+l
'
Worksheets("colour full").Activate
Worksheets("colour full").Range("A1").Activate
ActiveCell.Columns("A:A").EntireColumn.Select
For Each Cell In Worksheets("colour").Range("ColourID")
Cells.Replace What:=Cell.Value, Replacement:=Cell.Offset(0,
1).Value, _
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False
Next

End Sub

Many thanks
Simon

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Replace script

Hi, in my opinion, the range (ColourID) seems to dictate the cells being
affected. Try increasing the range.

" wrote:

Hi everyboby
I'm having a problem with a short replace macro i'm trying to write in
excel

I have two sheets on the same workbook one called "colour full" and
one called "colour"
Sheet "colour" contains a table with colour code (range name
"ColourID") and the coresponding
description. Sheet "colour full" contains a column of colour code
which i would like to replace with the description.

my problem seems to be the
For Each Cell In Worksheets("colour").Range("ColourID")
line as the script only replaces the first row on the sheet "colour",
not then moving down to the next row and repeating the replace
function untill it has run to the end of the "ColourID" range.

No doubt it is a stupid/obvious error I have made but I'm new to this
and any help would be much apreciated as i have a lot of these replace
tasks to do.


Sub colour()
'
' colour Macro
'
' Keyboard Shortcut: Ctrl+l
'
Worksheets("colour full").Activate
Worksheets("colour full").Range("A1").Activate
ActiveCell.Columns("A:A").EntireColumn.Select
For Each Cell In Worksheets("colour").Range("ColourID")
Cells.Replace What:=Cell.Value, Replacement:=Cell.Offset(0,
1).Value, _
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False
Next

End Sub

Many thanks
Simon


Reply
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
Replace text with variable using VBA replace code? Mike[_112_] Excel Programming 2 November 9th 06 06:06 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
How can I use replace(alt+H) for mutiple items needing replace Gery Excel Worksheet Functions 1 June 15th 05 05:51 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
VB Script To replace space with nothing JonEx2k2 Excel Programming 1 March 1st 04 09:26 PM


All times are GMT +1. The time now is 07:33 PM.

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"