It has been some time since I had to do some programming however; I am muttling through this project that I've been given. I am stumped at the moment and would appreciate some guidance from you guys. I have the following table and have my script to identify a change in software title and assign the start row and end row as the range for column c. I now need to search this range for the word "core", "standard", "approved" and if found replace all occurances of "prohibited" and "new" with the found word. For example for the Software Title "1-2-3", MyRange is C2:C6, and Prohibited and New would be replaced by Core.
[TABLE="width: 279"]
<tbody>[TR]
[TD]Software Title[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Prohibited[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Prohibited[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Core[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]New[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Prohibited[/TD]
[/TR]
</tbody><colgroup><col><col></colgroup>[/TABLE]
My code thus far is:
Sub Compare_Cells()
Dim i, FirstRow, LastRow, A, B, C As Integer
Dim r As Long
Dim firstTime As Integer
Dim bNotFound As Boolean
Dim String1, String2, String3, String4, String5, String6, Txt As String
Dim Status As Range
i = 2
FirstRow = i
LastRow = i - 1
bNotFound = True
Do While bNotFound
FirstRow = LastRow + 1
String1 = Worksheets("Sheet1").Cells(i, "B").Value
If String1 = "" Then
GoTo MyEnding
End If
i = i + 1
String2 = Worksheets("Sheet1").Cells(i, "B").Value
If StrComp(String1, String2, vbTextCompare) <> 0 Then
LastRow = i - 1
A = FirstRow
B = LastRow
Txt = "Core"
Set Status = Range(Cells(FirstRow, 3), Cells(LastRow, 3))
MsgBox "Core Found in Cell " & Value = Status.Address
'Do
'Replacement = ActiveCell.Value
'Replacement = "Core"
'Range("C" & FirstRow & ":C" & LastRow).Select
'Selection.Replace What:=",", Replacement:=Replacement, LookAt:=xlPart, _
'SearchOrder:=xlByRows, MatchCase:=False
'RowNum = RowNum + 1
'Range("B" & RowNum).Select
'Loop Until ActiveCell.Value = ""
End If
Loop
MyEnding:
bNotFound = False
MsgBox "End of Program"
End Sub
[TABLE="width: 279"]
<tbody>[TR]
[TD]Software Title[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Prohibited[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Prohibited[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Core[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]New[/TD]
[/TR]
[TR]
[TD]1-2-3[/TD]
[TD]Prohibited[/TD]
[/TR]
</tbody><colgroup><col><col></colgroup>[/TABLE]
My code thus far is:
Sub Compare_Cells()
Dim i, FirstRow, LastRow, A, B, C As Integer
Dim r As Long
Dim firstTime As Integer
Dim bNotFound As Boolean
Dim String1, String2, String3, String4, String5, String6, Txt As String
Dim Status As Range
i = 2
FirstRow = i
LastRow = i - 1
bNotFound = True
Do While bNotFound
FirstRow = LastRow + 1
String1 = Worksheets("Sheet1").Cells(i, "B").Value
If String1 = "" Then
GoTo MyEnding
End If
i = i + 1
String2 = Worksheets("Sheet1").Cells(i, "B").Value
If StrComp(String1, String2, vbTextCompare) <> 0 Then
LastRow = i - 1
A = FirstRow
B = LastRow
Txt = "Core"
Set Status = Range(Cells(FirstRow, 3), Cells(LastRow, 3))
MsgBox "Core Found in Cell " & Value = Status.Address
'Do
'Replacement = ActiveCell.Value
'Replacement = "Core"
'Range("C" & FirstRow & ":C" & LastRow).Select
'Selection.Replace What:=",", Replacement:=Replacement, LookAt:=xlPart, _
'SearchOrder:=xlByRows, MatchCase:=False
'RowNum = RowNum + 1
'Range("B" & RowNum).Select
'Loop Until ActiveCell.Value = ""
End If
Loop
MyEnding:
bNotFound = False
MsgBox "End of Program"
End Sub