Rebecca Schroder
New Member
Members
Excel Tables
Excel Tables
Forum Posts: 1
Member Since:
February 14, 2020
February 14, 2020
Offline
I'm trying to learn VBA, but I'm really stuck.
Each month new data (from the previous month) is pasted over the old data. The number of days each month changes due to nonwork days. I've tried clearing the cells and pasting data in blank cells, but this messes up the associated charts and graphs. Eventually I will learn how to have VBA create new charts, but I'm not there yet. I want to delete entire rows with data before the last month, day 1.
I've read so many posts and I've tried so many ways. I'm just not getting it and I'm losing my mind!
Sub ltest()
Dim d As Date
d = DateAdd("y", -1, Date)
LastMonth = Month(DateAdd("m", -1, Date))
Dim w As Long
For w = Sheet1.[a4].SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
Debug.Print Cells(w, "A").Value
If CDate(Cells(w, "A")) < CDate(LastMonth) Then
Cells(w, "A").EntireRow.Delete
End If
Next w
End Sub
I hope that I have posted this correctly and I really appreciate any help.
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Riny van Eekelen
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1939
SunnyKow: 1432
Anders Sehlstedt: 919
Purfleet: 415
Frans Visser: 349
Hans Hallebeek: 339
David_Ng: 306
lea cohen: 248
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
Drew Smith
Michael Denton
Nick Pascal
David Webb
Johannes Bruentrup
John Jay
Larry Silverman
David Rousseau
Melinda Heidemann
Jose Fuentes
Forum Stats:
Groups: 3
Forums: 25
Topics: 7073
Posts: 30998
Member Stats:
Guest Posters: 49
Members: 34470
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —