I have a macro where a user is prompted to enter a date (4/27/21 for example) and then vba will search a named range (date_range) for EVERY cell that has the input. Then I need to copy the entire row where the date was found and paste it onto another worksheet. I have attached a snippet of the worksheet range that I am searching, it is much larger but as an example should be okay. Some of the date fields in the range are populated by a formula and when they're copied over to a new sheet there is an error. I have two issues:
1.) This code works if I step through it in the debugger. but when I run it, excel freezes for awhile before crashing. The data range is $G$5:$AS$175. is that too big to search for a user inputted date?
2.) How can I fix the formula errors when copying over the rows to another worksheet?
Dim key As Variant
Dim c As Range
Dim firstaddress As String
Dim n As Integer
n = 0
key = InputBox("Please enter a date", "Search")
With Worksheets("Data").Range("date_range")
Set c = .Find(key, LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Address
Do
c.EntireRow.Copy Sheets("Search").Range("A2").Offset(n, 0)
Set c = .FindNext(c)
n = n + 1
Loop While Not c Is Nothing
End If
End With