Hi Joe.
The macro has to replace multiple cells in one column based on a condition. What I need is a looping of this macro for x columns. For instance, the macro begins at yellow cell column, after that is moves to Column D, E. F, G .....
5828 is the number of the columns. But I can not mantain this value fixed, because sometimes I have more ou less column than that, so I need to input the value for every run.
thank you so much for your response
Sub Macro3()
'
'
'
Dim Rng As Range
Dim WorkRng As Range
Dim wb1 As Workbook
Set wb1 = ActiveWorkbook
Dim Replacement(2) As String
Dim x As Integer
Dim RAN As Range
Dim Z As Integer
Set RAN = ActiveCell
Application.ScreenUpdating = False
If RAN.Value = "A/G" Then
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(1, 0).Replace What:="AA", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Offset(1, 0).Replace What:="GG", Replacement:="-1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Else
If RAN.Value = "G/T" Then
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Offset(1, 0).Replace What:="GG", Replacement:="-1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Offset(1, 0).Replace What:="TT", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Else
If RAN.Value = "G/C" Then
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Offset(1, 0).Replace What:="GG", Replacement:="-1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Offset(1, 0).Replace What:="CC", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Else
If RAN.Value = "C/T" Then
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Offset(1, 0).Replace What:="CC", Replacement:="-1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Offset(1, 0).Replace What:="TT", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Else
If RAN.Value = "A/C" Then
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Offset(1, 0).Replace What:="AA", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Offset(1, 0).Replace What:="CC", Replacement:="-1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Else
If RAN.Value = "A/T" Then
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Offset(1, 0).Replace What:="AA", Replacement:="-1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Offset(1, 0).Replace What:="TT", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
End If
End If
End If
End If
End If
ActiveCell.Offset(0, 1).Select
Application.ScreenUpdating = True
End Sub