Find date and copy range based on that date

A

avzundert

Hi,

I'd like to have a VBA routine who does the following:

- Look in a cell what date is stored in it.
- Find that date in a very large column 'A'.
- Select the found date in column 'A' together with the next 5 column
and 5 rows down.
- Copy this range to another location.

Please, respond
 
J

Jason Morin

Not perfect, but should get you started:

Sub test()
Dim irow As Long
Dim ival As Range, icol As Range
Dim idesta As Range

Set ival = Sheets("Sheet2").Range("F1")
Set icol = Sheets("Sheet2").Range("A:A")
Set idest = Sheets("Sheet3").Range("A1")

irow = 0
On Error Resume Next
irow = Application.WorksheetFunction. _
Match(ival, icol, 0)
On Error GoTo 0

If irow <> 0 Then
Range("A" & irow).Resize(5, 6).Copy (idest)
Else
MsgBox ival & " not found."
End If

End Sub

---

F1 contains the value to look for, and the "other
location" to copy to is Sheet3!A1.

HTH
Jason
Atlanta, GA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top