View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Find the correct sheet then find a value on that sheet

Hi Howard,

Am Mon, 18 Nov 2013 00:47:14 -0800 (PST) schrieb Howard:

This code, in sheet 1 module, searches the other sheets for a date in cell A1. When found then that sheet's A1 is activated by the Application.Goto RngD, True.

What I am having trouble with is, now that I have the correct sheet I want to GoTo a value on that sheet that is listed from C5: to however many rows there may be. (I assume the GoTo A1 is not needed as the code that finds the Column C value will have a GoTo.)

I have tried a Set RngS = .Find(What:=FindStore, _etc. following the
Set RngD = .Find(What:=FindDate, _ but I get an Improper Call error.

So find the sheet that has the Range("D8").Value and once there find the Cell in Column C that has the Range("D4").Value and GoTO it.


try:
Sub SearchAOne()
Dim FindDate As Date
Dim FindStore As String 'Dimmed but not used yet
Dim RngD As Range
Dim RngS As Range 'Dimmed but not used yet
Dim ws As Worksheet
Dim cnt As Integer
Dim LRow As Long
FindStore = Sheets("Sheet1").Range("D4").Value 'Dimmed but not used
yet
FindDate = Sheets("Sheet1").Range("D8")

If FindDate 0 Then
For Each ws In ThisWorkbook.Worksheets
With ws.Range("A1")
Set RngD = .Find(FindDate, LookIn:=xlValues)
If Not RngD Is Nothing Then
Application.Goto RngD
Exit For
End If
End With
Next ws
End If
If Not RngD Is Nothing Then
With ActiveSheet
LRow = .Cells(.Rows.Count, 3).End(xlUp).Row
Set RngS = .Range("C5:C" & LRow).Find(FindStore, _
LookIn:=xlValues)
If Not RngS Is Nothing Then
RngS.Select
Else
MsgBox "No value for FindStore"
End If
End With
Else
MsgBox "No date found"
End If
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2