for each item in 1 sheet search for it in another and execute code

lucas50nj

New Member
Joined
Jun 13, 2018
Messages
9
Hi, again I’m new to macro writing so please be patient with me.
Thank you!!

What I have is:
I have sheet 2 as my active sheet
Sheet 1 as my source sheet

What I need to do is:
Read column A in sheet 2 and for every item in column A I want to look for it in sheet 1 (source sheet) column A and then execute another code which I will call and it’s tested and works. Please keep in mind that sheet 1 column A will have blanks so it must continue to search in column A until found.
If you feel that I must change my active sheets around please let me know.
Please let me know if you need anything else.
I truly appreciate this.
Fernando
My code:

Sub readfromlist()
Dim row, rngRow As Long
Dim c As Range
Dim rngSearch As Range, rngFound As Range
Dim srchRow, lastrow As Integer
Dim x As Integer
Dim Llastrow As Integer
'Dim Llastrow As Long
'***************This code moves down column A to the end of the list:************************
Sheets("list1").Activate
'Set numrows = number of rows of data.
numrows = Range("A2", Range("A2").End(xlDown)).Rows.Count
Range("A2").Select
MsgBox numrows
For x = 1 To numrows
Set Source = ActiveWorkbook.Worksheets("main")
rngRow = Source.Range("A3").End(xlDown).row
Range("A3").Select



'**************This moves content of column M to D and E**********************************
‘’’’’This section works’’’’’
Llastrow = Source.Range("M4").End(xlDown).row
For row = 4 To Llastrow
If Range("m" & row).Value Like "*:*" Then 'if found then move it to d column
Range("d" & srchRow).Value = Range("m" & row).Value
Range("m" & row).Value = ""
ElseIf Range("m" & row).Value <> "" Then 'if found then move it to e column
Range("E" & srchRow).Value = Range("m" & row).Value
Range("m" & row).Value = ""
End If
srchRow = srchRow + 1
Next 'End of for "row" loop
ActiveCell.Offset(1, 0).Select 'Selects cell down 1 row from active cell.
Next 'End of for x loop
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
lucas50nj,

So that we can get it right on the first try, can we see your actual raw data workbook/worksheets, and, can we see on another worksheet what the results (manually formatted by you) should look like?

You can post your workbook/worksheets to the following free site (sensitive data changed), mark the workbook for sharing, and, provide us with a link to your workbook:

https://dropbox.com
 
Upvote 0
Hello hiker95 and thank you for helping. Not sure if this list will help. The info below would be in both sheets 1 and 2 but sheet 1 will contain spaces between rows that's why I decided to put the same list on sheet 2 so it won't contain spaces. The manual results follow the projects. the example is for the CU FAD Application project. My code is suppose to look for each project and insert rows and project status. The insert of rows and data works, I just can't get around the search problem due to the fact that the project column has empty rows.
thanks again!!

[TABLE="width: 137"]
<colgroup><col></colgroup><tbody>[TR]
[TD]PROJECTS[/TD]
[/TR]
[TR]
[TD]NAME[/TD]
[/TR]
[TR]
[TD]NYSPI Intranet Redesign/MIND mySQL Upgrade[/TD]
[/TR]
[TR]
[TD]2018 Efficiencies[/TD]
[/TR]
[TR]
[TD]NY.gov ID Federation:[/TD]
[/TR]
[TR]
[TD]CU FAD Application Updates[/TD]
[/TR]
[TR]
[TD]CU Grant Master[/TD]
[/TR]
[TR]
[TD]CAMRS[/TD]
[/TR]
[TR]
[TD]DCM Per Diem Census[/TD]
[/TR]
[TR]
[TD]FTask[/TD]
[/TR]
[TR]
[TD]Space Administration[/TD]
[/TR]
[TR]
[TD]WebFtask[/TD]
[/TR]
[TR]
[TD]INFOED DCM Lab Animals Module[/TD]
[/TR]
[TR]
[TD]INFOED DCM Animal Facilities Module[/TD]
[/TR]
[TR]
[TD]TIQR[/TD]
[/TR]
[TR]
[TD]YOGI Reporter[/TD]
[/TR]
[TR]
[TD]RFMH Grant Master[/TD]
[/TR]
[TR]
[TD]RFMH Subcontract Application[/TD]
[/TR]
[TR]
[TD]RFMHAdmin[/TD]
[/TR]
[TR]
[TD]RFMH Server Migration to NYSPI[/TD]
[/TR]
[TR]
[TD]DNN ServiceNet Website[/TD]
[/TR]
[TR]
[TD]Security Login Enhancement (DLL) - For all RFMH Applications[/TD]
[/TR]
[TR]
[TD]RFMH ORACLE Projects/Upgrades[/TD]
[/TR]
[TR]
[TD]RFMH SQL Environment Upgrade[/TD]
[/TR]
[TR]
[TD]RFMH Business Office / Office 365 Upgrade[/TD]
[/TR]
[TR]
[TD]Data Analysis / Ad-hoc Reporting[/TD]
[/TR]
[TR]
[TD]SQL TASKS[/TD]
[/TR]
[TR]
[TD]IRB - PRISM[/TD]
[/TR]
[TR]
[TD]IRB - PMS[/TD]
[/TR]
[TR]
[TD]IRB - FCOI[/TD]
[/TR]
[TR]
[TD]IT Support Requests[/TD]
[/TR]
[TR]
[TD]RNAC / Microsope Program[/TD]
[/TR]
[TR]
[TD]Research Pharmacy Database Integration[/TD]
[/TR]
[TR]
[TD]Handler & Division Status Reports[/TD]
[/TR]
[TR]
[TD]KIS EMR[/TD]
[/TR]
[TR]
[TD]Workforce IS Support[/TD]
[/TR]
[TR]
[TD]LAMP Migration to ubuntu[/TD]
[/TR]
[TR]
[TD]Workforce IS SDT[/TD]
[/TR]
[TR]
[TD]Residency Candidate IS[/TD]
[/TR]
</tbody>[/TABLE]


[TABLE="width: 940"]
<colgroup><col span="3"><col><col></colgroup><tbody>[TR]
[TD]CU Grant Master[/TD]
[TD]Application Development[/TD]
[TD]John [/TD]
[TD]Issues:[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]Certain people not populating CU sal data on Compensation tab in FAD[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Eugene : re-install FAD - lost icon on desktop[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Amy : re-install FAD - lost icon on desktop[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Eli Fontan: Trying to run report using report generator - email fields not updated(correct) on report[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]Location field is saving change when additional field in record is changed. This should not occur unless person is Non-Pac.[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Eugene Nor: re-install FAD and re-map HENRY - PsyIT set up new profile on computer.[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Amy : remote training on FAD Report Generator[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Tania : Set up as new FAD user and Install FAD on computer[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]UNI incorrect in some records in CFAD[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]User Access:[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Christine : Access for Yeny [/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Monthly Process:[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]Import of CU data for FAD[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]January 2017 - Rich[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]January 2017 - Rex[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]February 2017 - Rich[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]February 2017 - Rex[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]March 2017 - Rich[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD]March 2017 - Rex[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi Hiker95,
I downloaded dropbox and installed it but it tells me that my computer is offline so I can't connect. May be related to internal network security. Is there any other way we can do this?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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