copy variable range

phillypdh

Board Regular
Joined
Jun 23, 2011
Messages
66
i have data with four columns of text however each day the length the data varies. i need to search a date field for a specific day (col A). when the date is found i need to copy columns B-D for each record with that date dynamically. then paste to another worksheet. if anyone can help me get started i would apprecialte it.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
This is what AutoFilter is for.

1) Turn on the macro recorder
2) Click the headers in row1 of your data
3) Turn on the Data > Filter > AutoFilter
4) Use the drop down in column A to filter for the date you want
5) Copy all remaining visible rows to another sheet
6) Turn off the Autfilter and stop the macro recorder


You should be able to edit that resulting code to be dynamic and reusable. Post that code here and we can help with that.
 
Upvote 0
But... if you can record your actions for just one of the dates (following Jerry's instructions) and show us the code that gets generated by the macro recorder we can amend it to repeat itself for each date it finds in column A.
 
Upvote 0
.... or give you a popup where you can enter the date you want, then the autofilter will run/copy on its own for that date...
 
Upvote 0
here is the code that was returned from the recorder.
Code:
Sub Macro4()
'
' Macro4 Macro
'
'
   
    Rows("2:2").Select
    Selection.AutoFilter
    ActiveWindow.LargeScroll ToRight:=-1
    ActiveSheet.Range("$A$2:$N$24459").AutoFilter Field:=1, Operator:= _
        xlFilterValues, Criteria2:=Array(2, "8/22/2011")
    ActiveWindow.SmallScroll Down:=-15
    Range("B3870:D3870").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top