ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple "Left" Problem (https://www.excelbanter.com/excel-programming/413977-simple-left-problem.html)

James8309

Simple "Left" Problem
 
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,

[email protected]

Simple "Left" Problem
 
Try this:

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

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

On Jul 13, 9:45*pm, James8309 wrote:
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,



James8309

Simple "Left" Problem
 
On Jul 14, 10:45*am, James8309 wrote:
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

Rick Rothstein \(MVP - VB\)[_2310_]

Simple "Left" Problem
 
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


"James8309" wrote in message
...
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,




All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com