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
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