BLACK FRIDAY SALE 20% OFF ALL COURSES

Rebecca Schroder
New Member
Members
Excel Tables
Excel Tables

Forum Posts: 1
Member Since:
February 14, 2020
February 14, 2020

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: Timothy, Velouria, Jill Niemeier, Pam Baillie, Stacey Wells, Phil Bradley, Todd Heckman
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1864
SunnyKow: 1432
Anders Sehlstedt: 886
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 241
Hans Hallebeek: 227
Jessica Stewart: 219
A.Maurizio: 213
Newest Members:
Kelvin H
Anya Ledwith
Mark Melvin
Stuart McInnes
Naji Moukhachen
Robert Mason
Debora Cohen
Kris Whitaker
Rajesh Jawajala
Todd Heckman
Forum Stats:
Groups: 3
Forums: 24
Topics: 6641
Posts: 29138
Member Stats:
Guest Posters: 49
Members: 33095
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —
