
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: Alain Balken
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27793
Member Stats:
Guest Posters: 49
Members: 32324
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —
