Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2003, 05:44 AM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel Automation Find Method

Hello,

Please can anyone help me with the syntax? I have a value, and I need to find the correct cell in the spreadsheet which matches that value.

So far I have:

Dim mytarget As Range

Set objXL = CreateObject("EXCEL.Application")
Set myWB = objXL.Workbooks.Open("C:\testsheet.xls")
Set myWS = myWB.Sheets("Sheet1")
i = 1


StrDate = Right(strArrayNames((i), 1), 8)
' for testing only
StrDate = "12 March 2003"

    Set mytarget = myWS.Range("a1", "z10")
    Set mytarget = mytarget.Find(StrDate)
    ActiveCell(mytarget).Select


I don't think this is right, but I am unsure what to do to put it right.

Any help would be greatly appreciated

John
 
Old September 17th, 2003, 06:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The quick answer is to alter your code

Code:
ActiveCell(mytarget).Select
to

Code:
myRange.Select

you might also want to add some of the search options to your code i.e.

Code:
Set mytarget = mytarget.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte )
check VBA help for explanations of these, but I think you probably only need 'What', 'Lookin' and 'lookat'.

HTH

Chris


There are two secrets to success in this world:
1. Never tell everything you know





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Automation MAKO C# 0 August 16th, 2006 01:05 PM
Excel VB Automation jeannief Excel VBA 3 June 14th, 2005 06:06 AM
Excel Automation ameysun C# 0 November 4th, 2004 07:33 AM
Excel Automation ameysun Pro VB 6 0 November 4th, 2004 02:55 AM
access to excel automation...seem to still have a mytfein Access VBA 0 September 9th, 2004 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.