Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Need help with code debug please

Public Sub FixASTBs()

Dim wsC As Worksheet
Dim r As Long
Dim myRange As Range

Set wsC = Sheets("Sheet1")

wsC.Activate
Range("E1").Select
Set myRange = wsC.UsedRange
r = ActiveCell.Row
If myRange("E" & r) = [*"ast"*] Then myRange("E" & r).Value = "ASTB" And
myRange("F" & r).Value = "AST"
r = r + 1
Set wsC = Nothing
End Sub

I need to find any cell in column E that contains the letters "ast" (whole
or part of cell). If this is true, I need to replace the whole cell's
contents with "ASTB", and also replace the contents of Column F with "AST"

Debug brings me to "If my Range..." line

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with code debug please

Sub FixASTBs()
Dim myRange as Range, cell as Range
On Error Resume Next
With worksheets("Sheet1")
set myRange = .Range(.Cells(1,"E"),.Cells(rows.count,"E").End(xl up)) _
.SpecialCells(xlConstants,xlTextValues)
End With
On Error goto 0
if myRange is nothing then exit sub
for each cell in myRange
if Ucase(cell.Value) like "*AST*" then
cell.offset(0,1).Value = "AST"
cell.Value = "ASTB"
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"justme" wrote in message
...
Public Sub FixASTBs()

Dim wsC As Worksheet
Dim r As Long
Dim myRange As Range

Set wsC = Sheets("Sheet1")

wsC.Activate
Range("E1").Select
Set myRange = wsC.UsedRange
r = ActiveCell.Row
If myRange("E" & r) = [*"ast"*] Then myRange("E" & r).Value = "ASTB" And
myRange("F" & r).Value = "AST"
r = r + 1
Set wsC = Nothing
End Sub

I need to find any cell in column E that contains the letters "ast" (whole
or part of cell). If this is true, I need to replace the whole cell's
contents with "ASTB", and also replace the contents of Column F with "AST"

Debug brings me to "If my Range..." line

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Need help with code debug please

:) :) :) :)
Worked perfectly!
Thanks!
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
debug code mohavv Excel Discussion (Misc queries) 1 November 27th 07 09:56 PM
Debug Error in Code Karen McKenzie Excel Discussion (Misc queries) 2 May 18th 07 04:25 PM
Excel 2000 Code works except in debug mode Bob Smedley Excel Programming 0 January 24th 06 01:21 AM
Code hangs Excel ... Why? ... and how can i debug?? Simon May Excel Programming 1 January 17th 05 06:22 AM
debug help Tom Ogilvy Excel Programming 0 August 27th 03 07:10 PM


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