Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Jeff Cunningham   on Sep 20 In MS Office Category.

  
Question Answered By: Dashiell Jones   on Sep 20

I tend to not "select/activate" a sheet if I don't have to to optimze
the codes. In this case, the code works  fine during the search
operation, but fails because the sheet that it needs to plop the rec'd
date on is not the activesheet, therefore it's dropped on the wrong
sheet (activesheet).

Like AJ said you have to specify which sheet to fill the date  on...
as "Sheets(k).Cells(rngA.Row, [e:e].Column).Value = recdate.text"

Here's the new code with the correct sheet explicitly defined:

Sub testRangeName()
Dim rngA As Range
Dim k As Integer
Dim aSheet() As Variant
Dim strTest As String

aSheet = Array("Telxon Repair History", "3870 Repair History", _
"SF51 Repair History")

For k = 0 To UBound(aSheet())
Set rngA = Sheets(aSheet(k)).Cells.Find(What:=recpo.text, _
SearchDirection:=xlPrevious, SearchOrder:=xlByRows)
If Not rngA Is Nothing Then
Sheets(aSheet(k)).Cells(rngA.Row,
[Received_Date].Column).Value = recdate.text
Exit Sub
End If
Next k
End Sub

Share: 

 

This Question has 17 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Find Value then Replace something else Or get search suggestion and latest updates.


Tagged: