Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Edit/Replace from table or named range?

Hello. I have a column of data in Sheet1, column A. I need to do a
bunch of Replaces on this data. Can vba refernece a table or named
range to loop through the Replaces? The table is on Sheet2, A2:B20.
Column A in the tabls is the "Find", and Col B is the "Replace with".
Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Edit/Replace from table or named range?

This is hard-coded, but could easily be tweaked to accomodate
anything.
Sub foofer()
For i = 2 To 20
Sheets("mainSheet").Range(Cells(1, 1), Cells(Rows.Count,
1)).Replace _
What:=Sheets("Sheet2").Cells(i, 1), _
Replacement:=Sheets("Sheet2").Cells(i, 2), _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next i
End Sub
Steve wrote:
Hello. I have a column of data in Sheet1, column A. I need to do a
bunch of Replaces on this data. Can vba refernece a table or named
range to loop through the Replaces? The table is on Sheet2, A2:B20.
Column A in the tabls is the "Find", and Col B is the "Replace with".
Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Edit/Replace from table or named range?

Thanks JW! How easy is it to take the above and used a named range?
I know for sure someone will monkey with the file and insert rows and
columns, which will royally screw things up!! Thanks for your help!

On Sep 11, 11:38 am, JW wrote:
This is hard-coded, but could easily be tweaked to accomodate
anything.
Sub foofer()
For i = 2 To 20
Sheets("mainSheet").Range(Cells(1, 1), Cells(Rows.Count,
1)).Replace _
What:=Sheets("Sheet2").Cells(i, 1), _
Replacement:=Sheets("Sheet2").Cells(i, 2), _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next i
End Sub



Steve wrote:
Hello. I have a column of data in Sheet1, column A. I need to do a
bunch of Replaces on this data. Can vba refernece a table or named
range to loop through the Replaces? The table is on Sheet2, A2:B20.
Column A in the tabls is the "Find", and Col B is the "Replace with".
Thanks!- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Edit/Replace from table or named range?

I'm personally not big on using named ranges in workbooks that are
used by multiple people. One of them can remove the named range too
easily for me. I recommend just establishing the bottom row of the
find_replace sheet and itterate through the For...Next as many times
as needed.
Sub foofer2()
Dim rng As Range
For i = 2 To Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("mainSheet").Range(Cells(1, 1), Cells(Rows.Count,
1)).Replace _
What:=Sheets("Sheet2").Cells(i, 1), _
Replacement:=Sheets("Sheet2").Cells(i, 2), _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next i
End Sub

Steve wrote:
Thanks JW! How easy is it to take the above and used a named range?
I know for sure someone will monkey with the file and insert rows and
columns, which will royally screw things up!! Thanks for your help!

On Sep 11, 11:38 am, JW wrote:
This is hard-coded, but could easily be tweaked to accomodate
anything.
Sub foofer()
For i = 2 To 20
Sheets("mainSheet").Range(Cells(1, 1), Cells(Rows.Count,
1)).Replace _
What:=Sheets("Sheet2").Cells(i, 1), _
Replacement:=Sheets("Sheet2").Cells(i, 2), _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next i
End Sub



Steve wrote:
Hello. I have a column of data in Sheet1, column A. I need to do a
bunch of Replaces on this data. Can vba refernece a table or named
range to loop through the Replaces? The table is on Sheet2, A2:B20.
Column A in the tabls is the "Find", and Col B is the "Replace with".
Thanks!- Hide quoted text -


- Show quoted text -


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
Edit the range of a pivot table Christine Excel Worksheet Functions 4 October 8th 09 06:31 PM
Edit replace within data table formula Dean[_8_] Excel Programming 2 February 2nd 07 01:06 AM
Edit/Replace from Table Steph[_6_] Excel Programming 1 February 28th 06 05:13 PM
How to edit a named range Wanson Excel Discussion (Misc queries) 0 December 8th 05 04:23 PM
How do I edit a Named Range using macro's behmer Excel Worksheet Functions 2 July 26th 05 09:02 PM


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