Hello,
I am new to VBA and largely have been attempting to teach myself how to do this with Google.
Essentially I want part of this macro to loop the 'Find' function to locate every instance of the text "#N/A" in a very large data set. If the line above the cell has data, I want to copy that data and paste it over the "#N/A" cell. If the line above does not have data, I want to copy the data from the cell below and paste it over the "#N/A" cell. If neither the cell above nor the cell below has data, I want it to just input "Filler" over the "#N/A" cell. And I want this to loop until there are no more "#N/A"s.
I know that this is not correct and only partially addresses what I am trying to do, but so far I have this:
If you could help me turn this into what I am trying to accomplish, that would be wonderful, but at the very least, could someone please assist me to code the looping lines correctly? What should the "Do" line read in order to run my code until there are no more results with the "Find" function.
I really appreciate any and all help and consideration!
I am new to VBA and largely have been attempting to teach myself how to do this with Google.
Essentially I want part of this macro to loop the 'Find' function to locate every instance of the text "#N/A" in a very large data set. If the line above the cell has data, I want to copy that data and paste it over the "#N/A" cell. If the line above does not have data, I want to copy the data from the cell below and paste it over the "#N/A" cell. If neither the cell above nor the cell below has data, I want it to just input "Filler" over the "#N/A" cell. And I want this to loop until there are no more "#N/A"s.
I know that this is not correct and only partially addresses what I am trying to do, but so far I have this:
VBA Code:
Do Until nullVal = False
Columns("D:D").Select
Selection.Find(What:="#N/A", After:=ActiveCell, LookIn:=xlFormulas2, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Select
If Not IsEmpty(ActiveCell.Offset(-1, 0)) Then
ActiveCell.Offset(-1, 0).Select
ActiveCell.Copy ActiveCell.Offset(1, 0)
ElseIf IsEmpty(ActiveCell.Offset(-1, 0)) Then
ActiveCell.FormulaR1C1 = "Filler"
End If
Loop
If you could help me turn this into what I am trying to accomplish, that would be wonderful, but at the very least, could someone please assist me to code the looping lines correctly? What should the "Do" line read in order to run my code until there are no more results with the "Find" function.
I really appreciate any and all help and consideration!
Last edited by a moderator: