ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - Code failing in Excel 97 (https://www.excelbanter.com/excel-programming/358085-vba-code-failing-excel-97-a.html)

Scott Wagner

VBA - Code failing in Excel 97
 
The following code is failing when users run in excel 97 on the "Replace" item.

Can you help?

Thanks in advance,

Scott

'----------------------------------------------------
'Remove unneeded text in column G
'----------------------------------------------------
Range("G2:G2000").Select
Dim Keywords As Variant
Dim Rng As Range
Dim Ndx As Long
Keywords = Array("Q Line ", "120 VAC ", "- Breaker ", " Standard")
For Each Rng In Selection.Cells
For Ndx = LBound(Keywords) To UBound(Keywords)
Rng.Value = Replace(Rng.Text, Keywords(Ndx), "")
Next Ndx
Next Rng

Doug Glancy

VBA - Code failing in Excel 97
 
Scott,

Off the top of my head, I think it's "Substitute" in 97.

hth,

Doug


"Scott Wagner" wrote in message
...
The following code is failing when users run in excel 97 on the "Replace"
item.

Can you help?

Thanks in advance,

Scott

'----------------------------------------------------
'Remove unneeded text in column G
'----------------------------------------------------
Range("G2:G2000").Select
Dim Keywords As Variant
Dim Rng As Range
Dim Ndx As Long
Keywords = Array("Q Line ", "120 VAC ", "- Breaker ", " Standard")
For Each Rng In Selection.Cells
For Ndx = LBound(Keywords) To UBound(Keywords)
Rng.Value = Replace(Rng.Text, Keywords(Ndx), "")
Next Ndx
Next Rng




Dave Peterson

VBA - Code failing in Excel 97
 
Replace was added in xl2k.

In xl97, you could use application.substitute().



Scott Wagner wrote:

The following code is failing when users run in excel 97 on the "Replace" item.

Can you help?

Thanks in advance,

Scott

'----------------------------------------------------
'Remove unneeded text in column G
'----------------------------------------------------
Range("G2:G2000").Select
Dim Keywords As Variant
Dim Rng As Range
Dim Ndx As Long
Keywords = Array("Q Line ", "120 VAC ", "- Breaker ", " Standard")
For Each Rng In Selection.Cells
For Ndx = LBound(Keywords) To UBound(Keywords)
Rng.Value = Replace(Rng.Text, Keywords(Ndx), "")
Next Ndx
Next Rng


--

Dave Peterson


All times are GMT +1. The time now is 12:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com