ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   using search function in macro (https://www.excelbanter.com/excel-discussion-misc-queries/44222-using-search-function-macro.html)

tam

using search function in macro
 
cells(1, 1).Formula = "=Search("":"",Sheet2!cells(1,1),1)"
What is wrong with this formula? How do I use this type of cell reference
in a formula?

Don Guillett

Look in vba help for using functions in macros or just use the FIND method
in vba instead. Also in HELP.

--
Don Guillett
SalesAid Software

"tam" wrote in message
...
cells(1, 1).Formula = "=Search("":"",Sheet2!cells(1,1),1)"
What is wrong with this formula? How do I use this type of cell reference
in a formula?




David Hepner

Try this:

Range("A1").Formula = "=Search("":"",Sheet2!cells(1,1),1)"



"tam" wrote:

cells(1, 1).Formula = "=Search("":"",Sheet2!cells(1,1),1)"
What is wrong with this formula? How do I use this type of cell reference
in a formula?


tam

Thanks, David. However, when I used this formula, I got "#NAME?". It looks
like the formula doesn't like the type of cell reference Cells(1,1). If I
changed cells(1,1) to A1, then everything worked fine. However, I have a
long list and I need to do a loop later on.
Regards,
Minh

"David Hepner" wrote:

Try this:

Range("A1").Formula = "=Search("":"",Sheet2!cells(1,1),1)"



"tam" wrote:

cells(1, 1).Formula = "=Search("":"",Sheet2!cells(1,1),1)"
What is wrong with this formula? How do I use this type of cell reference
in a formula?


David Hepner

This should work for you:

Worksheets("Sheet1").Cells(1, 1).Formula =
"=Search("":"",Sheet2!cells(1,1),1)"

"tam" wrote:

Thanks, David. However, when I used this formula, I got "#NAME?". It looks
like the formula doesn't like the type of cell reference Cells(1,1). If I
changed cells(1,1) to A1, then everything worked fine. However, I have a
long list and I need to do a loop later on.
Regards,
Minh

"David Hepner" wrote:

Try this:

Range("A1").Formula = "=Search("":"",Sheet2!cells(1,1),1)"



"tam" wrote:

cells(1, 1).Formula = "=Search("":"",Sheet2!cells(1,1),1)"
What is wrong with this formula? How do I use this type of cell reference
in a formula?


Dave Peterson

Depending on what your loop looks like...

Maybe you could do it like this instead of the loop:

Range("a1:A99").formula = "=Search("":"",Sheet2!A1,1)"


tam wrote:

Thanks, David. However, when I used this formula, I got "#NAME?". It looks
like the formula doesn't like the type of cell reference Cells(1,1). If I
changed cells(1,1) to A1, then everything worked fine. However, I have a
long list and I need to do a loop later on.
Regards,
Minh

"David Hepner" wrote:

Try this:

Range("A1").Formula = "=Search("":"",Sheet2!cells(1,1),1)"



"tam" wrote:

cells(1, 1).Formula = "=Search("":"",Sheet2!cells(1,1),1)"
What is wrong with this formula? How do I use this type of cell reference
in a formula?


--

Dave Peterson


All times are GMT +1. The time now is 03:54 AM.

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