![]() |
Find date and copy range based on that date
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 -- avzunder ----------------------------------------------------------------------- avzundert's Profile: http://www.excelforum.com/member.php...fo&userid=1680 View this thread: http://www.excelforum.com/showthread.php?threadid=32017 |
Find date and copy range based on that date
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 -----Original Message----- 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 columns and 5 rows down. - Copy this range to another location. Please, respond. -- avzundert --------------------------------------------------------- --------------- avzundert's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=16808 View this thread: http://www.excelforum.com/showthread...hreadid=320171 . |
Find date and copy range based on that date
Thanks Jason, for your quick response! I think it helps to solve m problem. : -- avzunder ----------------------------------------------------------------------- avzundert's Profile: http://www.excelforum.com/member.php...fo&userid=1680 View this thread: http://www.excelforum.com/showthread.php?threadid=32017 |
All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com