Forum Discussion
marking data
- Apr 20, 2018
Hi Wonder,
Sorry for the delay. Have some work. Use the macro below in your excel sheet.
Sub Macro1()
Dim a, f, t As IntegerIf Range("M3").Value = "A" Then
f = Range("N3").Value
t = Range("O3").Value
For i = f To t
Range("P3").Select
Selection.Copy
Range("A3:C8").Select
Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Next i
End IfIf Range("M4").Value = "B" Then
f = Range("N4").Value
t = Range("O4").Value
For i = f To t
Range("P4").Select
Selection.Copy
Range("E3:G8").Select
Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Next i
End IfIf Range("M5").Value = "A to B" Then
f = Range("N5").Value
t = Range("O5").Value
For i = f To 18
Range("P5").Select
Selection.Copy
Range("A3:C8").Select
Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Next i
For i = 1 To t
Range("P5").Select
Selection.Copy
Range("E3:G8").Select
Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Next i
End If
End Sub
This should be pretty easy to do with a few variables. If an expert doesn't give you a solution, I could probably come up with one for you.
Hi Brandon Gale,
In screen shot, in third box, B specified as 8 to 2, A to B specified as 6 to 9. But wrongly colored in A, B boxes.
In table A, 1 to 5 colored correctly in orange.
Confirm it.