Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using Cells.Find between 2 sheets

Sub ReadSheet1, which is roughly shown, reads down column
A in worksheet 1 (no problem), I'm having problems with
the sub ReadSheet2 (shown further down)in which I'd like
to find valueA in Sheet2 and change the color index in
that cell(s).

Any suggestions as to what I'm doing wrong???

Sub ReadSheet1()
Set currentCell = Worksheets(1).Range("A1")
LeeA = currentCell.Offset(0, 0)
Do
counter1 = counter1 + 1

Set nextCell = currentCell.Offset(1, 0)
valueA = currentCell.Offset(0, 0)

ReadSheet2(valueA)

Set currentCell = nextCell
Set nextCell = currentCell.Offset(counter1, 0)
Loop While True
End sub

Sub ReadSheet2(partNum)
Dim Range1 As Object
Set Range1 = Worksheets("Sheet2").Range("A1:A899")

On Error GoTo errorcode
Cells.Find(What:=partNum, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False).Activate

With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

Exit Sub
errorcode:
If Err = 91 Then
MsgBox ("part doesn't exist:" & Err)
Else
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
MsgBox ("part exists:" & Err)
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default using Cells.Find between 2 sheets

Is this what you're trying to do?

Sub ReadSheet2(partNum)
Dim Range1 As Range, rngFind As Range

Set Range1 = Worksheets("Sheet2").Range("A1:A899")

On Error GoTo errorcode

Set rngFind = Range1.Find(What:=partNum, LookIn:=xlFormulas,
LookAt:=xlWhole)
If Not rngFind Is Nothing Then
With rngFind.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
MsgBox ("Part doesn't exist.")
End If

Exit Sub

errorcode:

End Sub

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

Sub ReadSheet1, which is roughly shown, reads down column
A in worksheet 1 (no problem), I'm having problems with
the sub ReadSheet2 (shown further down)in which I'd like
to find valueA in Sheet2 and change the color index in
that cell(s).

Any suggestions as to what I'm doing wrong???

Sub ReadSheet1()
Set currentCell = Worksheets(1).Range("A1")
LeeA = currentCell.Offset(0, 0)
Do
counter1 = counter1 + 1

Set nextCell = currentCell.Offset(1, 0)
valueA = currentCell.Offset(0, 0)

ReadSheet2(valueA)

Set currentCell = nextCell
Set nextCell = currentCell.Offset(counter1, 0)
Loop While True
End sub

Sub ReadSheet2(partNum)
Dim Range1 As Object
Set Range1 = Worksheets("Sheet2").Range("A1:A899")

On Error GoTo errorcode
Cells.Find(What:=partNum, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False).Activate

With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

Exit Sub
errorcode:
If Err = 91 Then
MsgBox ("part doesn't exist:" & Err)
Else
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
MsgBox ("part exists:" & Err)
End If
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find value in Multiple Sheets jlclyde Excel Discussion (Misc queries) 4 January 15th 09 09:59 PM
how to find gst work sheets New User Excel Worksheet Functions 1 December 13th 06 08:24 PM
Find values from cells in multiple sheets asubramaniam Excel Worksheet Functions 2 July 24th 05 01:50 PM
how do i find which sheets contain links? dov Excel Worksheet Functions 2 April 12th 05 12:55 AM
Swapping between sheets & using Find Neil[_11_] Excel Programming 0 September 6th 03 09:37 PM


All times are GMT +1. The time now is 01:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"