Look for only exact match and not like match.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,

Mycode looks in col A but find the like match and then updates..please advice on what I should do to get exact match
I really doubt there is something wrong on the blue line....Is that coded correctly?
I am trying to find ik in A:A and then find "" cell below it and then paste the copied content..

Thanks alot for helping me in Advance
Pedie
Code:
[FONT=Arial]Sub Update()[/FONT]
[FONT=Arial]Application.ScreenUpdating = False[/FONT]
[FONT=Arial]Dim wb As Workbook, MyFile As String[/FONT]
[FONT=Arial]Dim ik As String[/FONT]
[FONT=Arial]ik = ThisWorkbook.Sheets("MyDATA").Range("C4").Value[/FONT]
[FONT=Arial]Sheets("MyDATA").Range("C2:C13").Copy[/FONT]
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
[FONT=Arial]MyFile = "C:\TRY.xls"[/FONT]
[FONT=Arial]   On Error Resume Next[/FONT]
[FONT=Arial]   Set wb = Workbooks.Open(Filename:=MyFile)[/FONT]
[FONT=Arial]   On Error GoTo 0[/FONT]
[FONT=Arial]   If wb Is Nothing Then MsgBox "File not in accessabl…": Exit Sub[/FONT]
[FONT=Arial]   Windows("TRY.xls").Activate[/FONT]
[FONT=Arial]   Sheets("MAIN").Activate[/FONT]
[FONT=Arial][COLOR=blue]    If Not ActiveWorkbook.ActiveSheet.Range("A1:A65500").Find(ik, LookAt:=xlWhole) Is Nothing Then[/COLOR][/FONT]
[FONT=Arial]    ActiveCell.Select[/FONT]
[FONT=Arial]    Do Until ActiveCell.Value = ""[/FONT]
[FONT=Arial]    ActiveCell.Offset(1, 0).Select[/FONT]
[FONT=Arial]    Loop[/FONT]
[FONT=Arial]    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _[/FONT]
[FONT=Arial]    xlNone, SkipBlanks:=False, Transpose:=True[/FONT]
[FONT=Arial]    wb.Close savechanges:=True[/FONT]
[FONT=Arial]    ThisWorkbook.Activate[/FONT]
[FONT=Arial]    Sheets("MyDATA").Select[/FONT]
[FONT=Arial]    Application.CutCopyMode = False[/FONT]
[FONT=Arial]    MsgBox "OK"[/FONT]
 
[FONT=Arial]    Else[/FONT]
[FONT=Arial]    wb.Close savechanges:=False[/FONT]
[FONT=Arial]    ThisWorkbook.Activate[/FONT]
[FONT=Arial]    Sheets("MyDATA").Select[/FONT]
[FONT=Arial]    Application.CutCopyMode = False[/FONT]
[FONT=Arial]    MsgBox ik & " not found...."[/FONT]
[FONT=Arial]   End If[/FONT]
[FONT=Arial]Application.ScreenUpdating = True[/FONT]
[FONT=Arial]End sub[/FONT]
<o:p></o:p>
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,216,499
Messages
6,131,010
Members
449,613
Latest member
MedDash99

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