So I am trying to get the following If then else statement to work. I believe I am having the most difficulty in getting the embedded loop to loop (the "else" part of the macro)
I believe the code shows what I am trying to do pretty clearly, which is if a cell in sheet1 equals a cell in sheet 2, make the original sheet 1 cell equal to a cell in sheet 2. the Part I am having trouble with is that if the cell doesn't equal the cell in sheet2, I want it to continue going down the list until it hits the cell for which it is equivalent.
Sub ReportGen()
Dim Rrow As Integer
Dim Rcol As Integer
Dim Mrow As Integer
Dim Mcol As Integer
Dim mNcol As Integer
Mcol = 2
mNcol = 6
Rcol = 2
Mrow = 2
For Rrow = 2 To 200
If Sheets("HTML_Raw").Cells(Rrow, Rcol).Text = Sheets("Master_Name_List").Cells(Mrow, Mcol).Text Then _
Sheets("HTML_Raw").Cells(Rrow, Rcol).Text = _
Sheets("Master_Name_List").Cells(Mrow, mNcol).Text
Else: If Sheets("HTML_Raw").Cells(row, Rcol).Text <> Sheets("Master_Name_List").Cells(Mrow, Mcol).Text Then _
Mrow = Mrow + 1
End If
Next Rrow
End Sub
Here's my Attempt at a Select Case way of doing this (also doesn't work but looks much cleaner)
Sub CaseTry1()
Dim Rrow As Integer
Dim Rcol As Integer
Dim Mrow As Integer
Dim Mcol As Integer
Dim mNcol As Integer
Dim Name As String
Dim CoName As String
Dim RawName As String
Mcol = 2
mNcol = 6
Rcol = 2
Mrow = 2
MasterN = Sheets("Master_Name_List").Cells(Mrow, mNcol)
CoName = Sheets("Master_Name_List").Cells(Mrow, Mcol)
RawName = Sheets("HTML_Raw").Cells(Rrow, Rcol)
Select Case CoName
Case Is = RawName
RawName = MasterN And Rrow = Rrow + 1
Case Else
Mrow = Mrow + 1
End Select
End Sub
Bookmarks