Update my code to handle dynamic range, copy/pate to new sheet then delete from main sheet

mag1c

New Member
Joined
Jul 18, 2018
Messages
2
Hi all,

I've create the below code which takes the date input from an inputbox as a variable, filters a column based on anything older than that date, selects the filtered criteria and then copy/pastes it to a new sheet and deletes it from the master sheet.

The problem is this criteria won't always reside in the same rows so I am needing to alter my code to make this dynamic, can anyone help me with this or point me in the right direction?


Code:
[FONT=&quot]     
    ReEnter:    myInputBoxTypeVariable = InputBox(Prompt:="Please enter the Date here")    If IsDate(myInputBoxTypeVariable) Then        MsgBox "Your input was: " & myInputBoxTypeVariable 'display message box with value held by variable        GoTo The_End    Else        MsgBox "Please try again and enter a date in the format MM/DD/YYYY"      GoTo ReEnter    End If    The_End: 'End of inputbox    Range("K2").Select    ActiveSheet.Range("$A$1:$S$7736").AutoFilter field:=11, Criteria1:= _        ">myInputBoxTypeVariable", Operator:=xlAnd 'contains the >myInputBoxTypeVariable (Date Selection)    Range("A2:S225").Select    Selection.Copy    Sheets("Exceptions Due to Date-Status").Select    Range("A2").Select    ActiveSheet.Paste    Sheets("Master Purge List").Select    Application.CutCopyMode = False    Selection.EntireRow.Delete
[/FONT]
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
StZNcNU
Here is a url to an image of my code since I did a horrible job wrapping it in code tags and can't edit my post and it won't let me insert an image

StZNcNU
StZNcNU
https://imgur.com/a/StZNcNU
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,849
Members
449,096
Latest member
Erald

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