Hello Guys,
Please note I already have my code ready but I guess I have an issue with the order that macro is not moving on the next values as A.
The macro basically does validationS based on the cells in column E for all values that has "A", but my actual code is configured to stop when the cell is empty and I need the macro still running until last cell with "A".
Guess I know what is the issue but not how to do it since I adapted a macro that I found in google about find values.
Thanks in advance
Andres
Please note I already have my code ready but I guess I have an issue with the order that macro is not moving on the next values as A.
The macro basically does validationS based on the cells in column E for all values that has "A", but my actual code is configured to stop when the cell is empty and I need the macro still running until last cell with "A".
VBA Code:
Sub FormatReport()
Application.ScreenUpdating = False
Dim strFirstAddress As String
Dim rngFindValue As Range
Dim rngSearch As Range
Dim rngFind As Range
Set rngFind = ActiveSheet.Range("E2:E1000000")
Set rngSearch = rngFind.Cells(rngFind.Cells.Count)
Set rngFindValue = rngFind.Find("A", rngSearch, xlValues)
Sheets("Temp to Submit").Select
Range("E2").Select
If Not rngFindValue Is Nothing Then
strFirstAddress = rngFindValue.Address
Do
Set rngFindValue = rngFind.FindNext(rngFindValue)
If ActiveCell.Value = "A" Then
ActiveCell.Offset(0, 4).Value = Date
ActiveCell.Offset(0, 5).Value = DateSerial(Year(Date), Month(Date) + 1, 1)
If ActiveCell.Value = "A" And ActiveCell.Offset(0, -1).Value = "" Then
ActiveCell.Offset(0, -1).Interior.ColorIndex = 6
End If
If ActiveCell.Value = "A" And ActiveCell.Offset(0, 1).Value = "X" Or ActiveCell.Offset(0, 1).Value = "x" Then
ActiveCell.Offset(0, -4).Select
Selection.Copy
ActiveCell.Offset(0, 3).PasteSpecial xlPasteValues
ActiveCell.Interior.ColorIndex = 34
ActiveCell.Offset(0, 1).Select
End If
If ActiveCell.Value = "A" And ActiveCell.Offset(0, 2).Value = "X" And ActiveCell.Offset(0, -2).Value = "1000" Or ActiveCell.Offset(0, -2).Value = "1006" Then
ActiveCell.Offset(0, -1).Value = "10009999"
ActiveCell.Offset(0, -1).Interior.ColorIndex = 34
If ActiveCell.Value = "A" And ActiveCell.Offset(0, 2).Value = "X" And ActiveCell.Offset(0, -2).Value = "1010" Then
ActiveCell.Offset(0, -1).Value = "10109901"
ActiveCell.Offset(0, -1).Interior.ColorIndex = 34
If ActiveCell.Value = "A" And ActiveCell.Offset(0, 2).Value = "X" And ActiveCell.Offset(0, -2).Value = "1020" Then
ActiveCell.Offset(0, -1).Value = "10203005"
ActiveCell.Offset(0, -1).Interior.ColorIndex = 34
If ActiveCell.Value = "A" And ActiveCell.Offset(0, 2).Value = "X" And ActiveCell.Offset(0, -2).Value = "1022" Then
ActiveCell.Offset(0, -1).Value = "10229001"
ActiveCell.Offset(0, -1).Interior.ColorIndex = 34
End If
End If
End If
End If
If ActiveCell.Value = "" Then
End If
ActiveCell.Offset(1, 0).Select
End If
Loop Until rngFindValue.Address = strFirstAddress
End If
End Sub
Guess I know what is the issue but not how to do it since I adapted a macro that I found in google about find values.
Thanks in advance
Andres