#1   Report Post  
Posted to microsoft.public.excel.misc
beatrice25
 
Posts: n/a
Default replacing macro?


Hi Everyone,
I have a sheet (actually hundreds of sheets)with data in B6 to I45,
inside it i need to make lots of replacements, e.g.
0 becomes DSR0
1 becomes DSR1
C1,C2,C3,C4,C5 become CTRL
How can I use a macro to do this and be able to add lines to it if i
want to do more replacements?

Also some cells make contain 10 or 11 for example, I do not want the
macro to change these just because they have a 0 or a 1 in them?

Any ideas?
I am still searching old questions in the forum to find the answer


Thanks for any help

B


--
beatrice25
------------------------------------------------------------------------
beatrice25's Profile: http://www.excelforum.com/member.php...o&userid=34505
View this thread: http://www.excelforum.com/showthread...hreadid=553813

  #2   Report Post  
Posted to microsoft.public.excel.misc
Mallycat
 
Posts: n/a
Default replacing macro?


It depends on the level of automation you want. A VBA macro would do
it


beatrice25 Wrote:
I have a sheet (actually hundreds of sheets)with data in B6 to I45,
inside it i need to make lots of replacements, e.g.
0 becomes DSR0
1 becomes DSR1
C1,C2,C3,C4,C5 become CTRL
How can I use a macro to do this



Sub ReplaceData()
Dim myRange As Range
Set myRange = Sheets("sheet1").Range("B6:I45") 'change sheet1 to
your sheet name
For Each cell In myRange
Select Case cell
Case 0
cell.Value = "DSR0"
Case 1
cell.Value = "DSR1"
Case C1, C2, C3, C4, C5
cell.Value = "CTRL"
End Select
Next cell
End Sub



and be able to add lines to it if i want to do more replacements?

this is harder. How will you know if you need more lines?


Also some cells make contain 10 or 11 for example, I do not want the
macro to change these just because they have a 0 or a 1 in
them?[/qoute]
the above macro will handle this.



--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile: http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=553813

  #3   Report Post  
Posted to microsoft.public.excel.misc
beatrice25
 
Posts: n/a
Default replacing macro?


Thanks MallyCat I will gove this a go,
Do I have to rename the sheet in the macro whenever I need to run it or
is there a way that I can get the macro to step through my hundreds of
sheets and make the replacements on the same location(B6:I45) on each
sheet?:


--
beatrice25
------------------------------------------------------------------------
beatrice25's Profile: http://www.excelforum.com/member.php...o&userid=34505
View this thread: http://www.excelforum.com/showthread...hreadid=553813

  #4   Report Post  
Posted to microsoft.public.excel.misc
beatrice25
 
Posts: n/a
Default replacing macro?


Thanks MallyCat I will gove this a go,
Do I have to rename the sheet in the macro whenever I need to run it or
is there a way that I can get the macro to step through my hundreds of
sheets and make the replacements on the same location(B6:I45) on each
sheet?:


--
beatrice25
------------------------------------------------------------------------
beatrice25's Profile: http://www.excelforum.com/member.php...o&userid=34505
View this thread: http://www.excelforum.com/showthread...hreadid=553813

  #5   Report Post  
Posted to microsoft.public.excel.misc
SimonCC
 
Posts: n/a
Default replacing macro?

From Mallycat's code,

below the line "Dim myRange As Range"
insert line "For Each Worksheet In Worksheets"

change the line "Set myRange = Sheets("sheet1").Range("B6:I45")"
to line "Set myRange = Worksheet.Range("B6:I45")"

below the line "Next cell"
insert line "Next Worksheet"

That should do it for every sheet.

-Simon

"beatrice25" wrote:


Hi Everyone,
I have a sheet (actually hundreds of sheets)with data in B6 to I45,
inside it i need to make lots of replacements, e.g.
0 becomes DSR0
1 becomes DSR1
C1,C2,C3,C4,C5 become CTRL
How can I use a macro to do this and be able to add lines to it if i
want to do more replacements?

Also some cells make contain 10 or 11 for example, I do not want the
macro to change these just because they have a 0 or a 1 in them?

Any ideas?
I am still searching old questions in the forum to find the answer


Thanks for any help

B


--
beatrice25
------------------------------------------------------------------------
beatrice25's Profile: http://www.excelforum.com/member.php...o&userid=34505
View this thread: http://www.excelforum.com/showthread...hreadid=553813




  #6   Report Post  
Posted to microsoft.public.excel.misc
beatrice25
 
Posts: n/a
Default replacing macro?


Thanks Simon, I really appreciate it

Beatrice


--
beatrice25
------------------------------------------------------------------------
beatrice25's Profile: http://www.excelforum.com/member.php...o&userid=34505
View this thread: http://www.excelforum.com/showthread...hreadid=553813

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
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 03:35 PM.

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"