rachel777


How do you add the sheet specifications to the code below so the code will look in column G in sheet named "Questions" for B2 text in sheet named "Solutions" The information for the two sheets are the following:

"rGCol" is in Sheet 1 named "Questions"

"sB2Text" is in Sheet 2 named "Solutions"

"G:G" is in Sheet 1 named "Questions"

Macro Code:

Sub Replace_For_Rachel()

Dim rGCol As Range
Dim sB2Text As String

Set rGCol = Range("G2:G" & CStr(Range("G:G").Cells.SpecialCells(xlCellTypeLastCell).Row))
sB2Text = Range("B2").Value

For Each gcell In rGCol
If gcell.Value = sB2Text Then
gcell.Value = 1
Else
gcell.Value = 0
End If
Next gcell

End Sub

Thank you!





Re: Find and Replace in Two Sheets

Adamus Turner


Sheets("SheetNameHere").Range("CellAddressHere").Value <--Must include double quotes

Adamus