Compare letters on Vba

sinanvarann

New Member
Joined
Dec 3, 2020
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
Hey guys I have a word like "abadi" and i want to enter a new word like "abc". If this abc letter a b and c are used on this word for once. Output should be at B1 cell. "abadi" has not "c" thats why its shouldn't work.
I coded it but there "abadi" consist 2 times "a" letter thats why counter takes "a" second time its shouldn't be. If i found "a" letter pass it in the another loop. I don't need another ways of solution I need only extract second same letter.
Program link is https://easyupload.io/el0xyb
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

Can you please rephrase your query. I have downloaded the file but unable to understand the requirement.

With few examples, can you share the expected output?

Thanks,
Saurabh
 
Upvote 0
Maybe
VBA Code:
Sub sinanvarann()
   Dim Txt As String
   Dim i As Long
   
   Txt = InputBox("Enter any word")
   For i = 1 To Len(Txt)
      If InStr(1, Cells(1, 1), Mid(Txt, i, 1), vbTextCompare) = 0 Then
         Exit Sub
      End If
   Next i
   Cells(1, 2) = Cells(1, 1)
End Sub
 
Upvote 0
Hi,

Can you please rephrase your query. I have downloaded the file but unable to understand the requirement.

With few examples, can you share the expected output?

Thanks,
Saurabh
 

Attachments

  • share.jpg
    share.jpg
    85.2 KB · Views: 3
Upvote 0
Maybe
VBA Code:
Sub sinanvarann()
   Dim Txt As String
   Dim i As Long
  
   Txt = InputBox("Enter any word")
   For i = 1 To Len(Txt)
      If InStr(1, Cells(1, 1), Mid(Txt, i, 1), vbTextCompare) = 0 Then
         Exit Sub
      End If
   Next i
   Cells(1, 2) = Cells(1, 1)
End Sub
Thank you but I cannot use another ways. Its an assignment thats why I can use only for, do while , if else , goto commands. If you try to fix my mistake in that file or adding somethings. I will be happy.
 
Upvote 0
In that case you should have said so in your original post. We are not here to do your homework for you, but will happily point you in the right direction.

You haven't posted any code for us to look at.
Okey thank you. So can i get any help to fix my program speed. I finished the code finally. But Its so slow. Excel freezing. I tried to use DoEvent after for loop. Still freezing.
 
Upvote 0
Can you please post the code you are using.
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top