At 14:26 27/01/2018 -0700, B J Lockie wrote:
I keep a spreadsheet with a monthly budget. Each month I copy a
month to make a new month. I use Fill to change the dates to the new
month. This is not ideal because sometimes there are 2 rows for the
same day and Fill changes the 2nd day. I need a macro just to change
the month and not the day.
Eg.
Jan 1 2018 | debit | ...
Jan 1 2018 | credit card | ...
Jan 2 2018 | credit card | ...
Using Fill to get a new section for Feb results in:
Feb 1 2018 | debit | ...
Feb 2 2018 | credit card | ...
Feb 3 2018 | credit card | ...
What I want is:
Feb 1 2018 | debit | ...
Feb 1 2018 | credit card | ...
Feb 2 2018 | credit card | ...
You don't say what is actually in your date column: text or proper
date values? I'm trusting you have the latter.
o Make your copy.
o In a spare column, enter =Xn+31 - where Xn is the first date value.
Don't worry about the formatting of that cell.
o Fill down that new column to create a set of new (February) dates
corresponding to your January dates.
o Cut (or copy) the new values and paste them back over the original
date column, but using Edit | Paste Special... (or Ctrl+Shift+V)
instead of ordinary Paste and ensuring that both Formulas and Formats
are *not* ticked in the Paste Special dialogue.
Using the formula =Xn+31, you clearly need to modify the 31 to the
length of whichever month you are extending from. Alternatively, you
could use other formulae to do this automatically, such as:
=DATE(YEAR(Xn);MONTH(Xn)+1;DAY(Xn))
or
=Xn+DAY(EOMONTH(Xn;0))
These formulae should roll over year ends appropriately, but in any
case, you will need to reduce or extend each month's rows to account
for different lengths of months, of course.
A macro? Is it worth it? That is left as an exercise for the reader!
I trust this helps.
Brian Barker
--
To unsubscribe e-mail to: [email protected]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted