Here is my current code:
Code:
Dim sh As Worksheet, sh2 As Worksheet
Dim LastRow As Integer
Dim LastRow2 As Integer
Set sh = Sheets("Raw ATS Data")
Set sh2 = Sheets("ATS Data")
With sh2
Range("A2:H" & Rows.Count).Clear
End With
LastRow = sh.Range("A1").End(xlDown).Row
sh.Range("A1:H" & LastRow).Copy
sh2.Range("A1").PasteSpecial xlPasteAll
sh2.Range("A1").PasteSpecial xlPasteColumnWidths
LastRow2 = sh2.Range("A1").End(xlDown).Row
Range("A1:H" & LastRow2).Select
Selection.Rows.AutoFit
Application.CutCopyMode = False
Application.DisplayAlerts = False
/code
I need to modify this so that it looks at the date from the "Power
Report" sheet in cell O1 and then finds all the dates within the last
14 days from the sh sheet in column B (row 2 and on) and then performs
the copy on only those rows within that date criteria. Row 1 contains
the data headers. There are also categories separator rows which always
contain the same names ("Static Drop", "Back Feed Drop", "Flip Failure", and
"Peripheral Drop")
so it looks like
Row 1 - Headers
Row 2 - Separator w/ label
Row 3 - x (current row 36) data
Row 37 (currently) - Separator w/ label
Row 38 - 43 - data
Row 44 (Currently) - Separator w/ label
Row 45 - Data
I will be adding data to this until the end of the year and then archiving it.
So I need a macro that is fluid enough to Always copy the separators and then
only the data that has the date as mentioned.
my VBA skills are somewhat new and I am struggling with the best way to
implement what I want to do. I considered a Match function that looked at the
date and then determined if it was within the last 14 days, or an ElseIf type
of implementation, or a Do Until. Just need a hand with the most efficient way
to modify the code and make it work.
--
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
https://www.facebook.com/discussexcel
FORUM RULES
1) Use concise, accurate thread titles. Poor thread titles, like Please Help,
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
NOTE : Don't ever post confidential data in a workbook. Forum owners and
members are not responsible for any loss.
---
You received this message because you are subscribed to the Google Groups "MS
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.