Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default problem in VB codes-2

hi ,
can anybody explain how I can use the loop below for "find" property in the
following code.I don't know why it can not jump to next I when "find"
property can not find the "/164" in the cells!!!????I know there are far
easier codes to do the substitution but I have to use the "find".thanx

Private Sub CommandButton4_Click()
Dim VAR As Variant
For I = 13 To 32
VAR = Application.WorksheetFunction.Find("/164", Cells(I, 2))
If VAR = 1 Then
Cells(I, 2) = Application.WorksheetFunction.Substitute(Cells(I, 2), "/164",
"")
Else
End If
Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default problem in VB codes-2

As I said in a previous post, I tested your code with 2/164 and it left me
with 2. But, then I showed you how to use vba replace. If you need to use
FIND, look in the vba help index for FINDNEXT. I guess this is homework so
you need to help yourself. You should NOT be using worksheet functions when
there are vba solutions.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"peyman" wrote in message
...
hi ,
can anybody explain how I can use the loop below for "find" property in
the
following code.I don't know why it can not jump to next I when "find"
property can not find the "/164" in the cells!!!????I know there are far
easier codes to do the substitution but I have to use the "find".thanx

Private Sub CommandButton4_Click()
Dim VAR As Variant
For I = 13 To 32
VAR = Application.WorksheetFunction.Find("/164", Cells(I, 2))
If VAR = 1 Then
Cells(I, 2) = Application.WorksheetFunction.Substitute(Cells(I, 2),
"/164",
"")
Else
End If
Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 638
Default problem in VB codes-2

You've got your arguments backwards.
Change This:
VAR = Application.WorksheetFunction.Find("/164", Cells(I, 2))
To This:
VAR = Application.WorksheetFunction.Find(Cells(I, 2), "/164")

peyman wrote:
hi ,
can anybody explain how I can use the loop below for "find" property in the
following code.I don't know why it can not jump to next I when "find"
property can not find the "/164" in the cells!!!????I know there are far
easier codes to do the substitution but I have to use the "find".thanx

Private Sub CommandButton4_Click()
Dim VAR As Variant
For I = 13 To 32
VAR = Application.WorksheetFunction.Find("/164", Cells(I, 2))
If VAR = 1 Then
Cells(I, 2) = Application.WorksheetFunction.Substitute(Cells(I, 2), "/164",
"")
Else
End If
Next
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default problem in VB codes-2

thanx Don,
I got your answers, but I just wanna know how I can apply loop for
"find".I'm just curious to know.that's it! by the way it's not a homework.
thanx anyway.

"Don Guillett" wrote:

As I said in a previous post, I tested your code with 2/164 and it left me
with 2. But, then I showed you how to use vba replace. If you need to use
FIND, look in the vba help index for FINDNEXT. I guess this is homework so
you need to help yourself. You should NOT be using worksheet functions when
there are vba solutions.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"peyman" wrote in message
...
hi ,
can anybody explain how I can use the loop below for "find" property in
the
following code.I don't know why it can not jump to next I when "find"
property can not find the "/164" in the cells!!!????I know there are far
easier codes to do the substitution but I have to use the "find".thanx

Private Sub CommandButton4_Click()
Dim VAR As Variant
For I = 13 To 32
VAR = Application.WorksheetFunction.Find("/164", Cells(I, 2))
If VAR = 1 Then
Cells(I, 2) = Application.WorksheetFunction.Substitute(Cells(I, 2),
"/164",
"")
Else
End If
Next
End Sub



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
problem in VB codes peyman Excel Discussion (Misc queries) 5 September 27th 07 06:16 PM
Help with codes Tom Excel Discussion (Misc queries) 4 September 18th 07 01:50 AM
Codes sam Excel Discussion (Misc queries) 2 September 11th 07 02:04 PM
VB Codes bowling Excel Discussion (Misc queries) 0 July 30th 07 07:02 PM
Zip Codes [email protected] Excel Discussion (Misc queries) 10 November 27th 04 05:23 PM


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