Find Macro

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon,

I am trying to create a Macro that will automatically populate a spreadsheet with information from another sheet within the same workbook.
The code keeps debugging @ the For Each MySht in MyWB.sheets
This should be looking at cell "D4" (MyManager) and pulling the information in as per the information below.

Sorry but i am stuck and unsure which direction to go in

Code:
Sub Start_Of_Macro()
    For Each MySht In MyWB.Sheets
        If MySht.Name = MyManager Then
            MySht.Select
            Exit For
        End If
   
Next MySht
 
Set MyFind = MySht.Columns(5).Find(what:=MyProcessNumber, searchdirection:=xlNext, lookat:=xlWhole)
If Not MyFind Is Nothing Then
    ExtractRow = MyFind.Row
Else
    MsgBox "Cannot find value " & MyProcessNumber
    Exit Sub
End If
Set MyFind = Nothing
DValue = Cells(ExtractRow, 1)
Sheets("Amend Quality").Cells(7, 7) = DValue
DAdvocate = Cells(ExtractRow, 2)
Sheets("Amend Quality").Cells(6, 4) = AdvocateValue 'Advocate Name
DYourName = Cells(ExtractRow, 3)
Sheets("Amend Quality").Cells(8, 4) = AssesorValue 'Assessor
DStatus = Cells(ExtractRow, 6)
Sheets("Amend Quality").Cells(11, 8) = StatusValue 'status
PReason = Cells(ExtractRow, 7)
Sheets("Amend Quality").Cells(13, 4) = ProcessValue 'process reason
PSReason = Cells(ExtractRow, 8)
Sheets("Amend Quality").Cells(13, 9) = ProcessSValue 'process Sub reason
Q1Value = Cells(ExtractRow, 9)
Sheets("Amend Quality").Cells(17, 11) = Q1Value 'Q1

All help appreciated.
Many Thanks
Gavin
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Code:
For Each MySht In MyWB.Sheets

What is MyWB - you haven't used a statement like

Code:
Set MyWB = WorkBooks("Test.xls")
 
Upvote 0
Cheers,

I realised just after i messaged you back.

It is erroring on

Code:
Set MyFind = MySht.Columns(5).Find(what:=MyProcessNumber, searchdirection:=xlNext, lookat:=xlWhole)

I havent specified "MyprocessNumber" previously as Public in another Module. Do i need to redfine this again in this module?

Many thanks
Gavin
 
Upvote 0
You need to define MyprocessNumber (and any other variables in other modules) as Public.
 
Upvote 0
Morning,

I already have defined "MyprocessNumber" as public in another module.
Do i still have to re do this in the present module?

Cheers
 
Upvote 0

Similar threads

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top