Simple "Left" Problem

  • Thread starter Thread starter James8309
  • Start date Start date
J

James8309

Hi everyone


I have a long Macro in one of my excel file and I am getting an object
defined error.

" Searchvalue = .Left(Range("A" & sh2rowcount), 9) "

I wanted my searchvaule to be left of that range. This is just a part
of my code and everything looks good except that line.

Where do I insert Left ? in order to search first 9 values of
Range("A" & sh2rowcount)??

Please help

Thank you,
 
Try this:

Searchvalue = .Left(Range("A" & CSTR(sh2rowcount)), 9)

I assume SH2ROWCOUNT is an integer and not a string?
Cheers
 
Hi everyone

I have a long Macro in one of my excel file and I am getting an object
defined error.

" Searchvalue = .Left(Range("A" & sh2rowcount), 9) "

I wanted my searchvaule to be left of that range. This is just a part
of my code and everything looks good except that line.

Where do I insert Left ? in order to search first 9 values of
Range("A" & sh2rowcount)??

Please help

Thank you,

Hi,

I tried adding cstr but still created an object error.



With Workbooks("513 Report.xls").Sheets("MF Lookup Phase2 - 10Digit")
sh2rowcount = 3
sh7rowcount = 3

Do While .Range("A" & sh2rowcount) <> ""
Searchvalue = .Left(Range("A" & CStr(sh2rowcount)), 9)
Set c = SearchRange3.Find(what:=Searchvalue, LookIn:=xlValues,
lookat:=xlWhole)
If c Is Nothing Then
With Workbooks("513 Report.xls").Sheets("MF Lookup Phase 2.1 -
10Digit")
.Range("A" & sh7rowcount) = "'" & Searchvalue
sh7rowcount = sh7rowcount + 1
End With
Else
.Range("B" & sh2rowcount) = c.Offset(0, 2)
.Range("C" & sh2rowcount) = c.Offset(0, 3)
End If
sh2rowcount = sh2rowcount + 1
Loop
End With
 
Do you have Searchvalue Dim'med as a Range (or some other object)?

Also, why do you show a 'dot' in front of the Left function?

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top