Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Linux: the choice of a GNU generation -- ksh@cis.ufl.edu put this on Tshirts in '93


computers / microsoft.public.excel.misc / Re: Static Date Insertion Formula

SubjectAuthor
* Re: Static Date Insertion FormulaJared Schmid
`- Re: Static Date Insertion FormulaPhilip Herlihy

1
Re: Static Date Insertion Formula

<8f59e925-d332-499d-ba1a-dab9d48536dcn@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=267&group=microsoft.public.excel.misc#267

  copy link   Newsgroups: microsoft.public.excel.misc
X-Received: by 2002:a37:6d1:0:b0:4b2:8a57:5755 with SMTP id 200-20020a3706d1000000b004b28a575755mr749259qkg.691.1646438663098;
Fri, 04 Mar 2022 16:04:23 -0800 (PST)
X-Received: by 2002:a05:6870:414e:b0:da:b3f:3237 with SMTP id
r14-20020a056870414e00b000da0b3f3237mr450278oad.231.1646438662776; Fri, 04
Mar 2022 16:04:22 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: microsoft.public.excel.misc
Date: Fri, 4 Mar 2022 16:04:22 -0800 (PST)
In-Reply-To: <92014F4D-7E6F-4E5E-97E5-124EBC2E07ED@microsoft.com>
Injection-Info: google-groups.googlegroups.com; posting-host=67.48.60.122; posting-account=UD2IoQoAAABV-QQAyVXGb3_exzj5Vhnb
NNTP-Posting-Host: 67.48.60.122
References: <AcbX+1EjUcOk/hPnTSW3l9ECOoy+0A==> <572B2607-E7ED-4A45-AA5D-0917095FD8EE@microsoft.com>
<483C5DC5-3514-4F35-A643-ABF003529C62@microsoft.com> <1D0EF067-D6A1-4410-9B5A-0EF5D663E8F7@microsoft.com>
<92014F4D-7E6F-4E5E-97E5-124EBC2E07ED@microsoft.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8f59e925-d332-499d-ba1a-dab9d48536dcn@googlegroups.com>
Subject: Re: Static Date Insertion Formula
From: jared.sc...@visitbicycleworld.com (Jared Schmid)
Injection-Date: Sat, 05 Mar 2022 00:04:23 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 26
 by: Jared Schmid - Sat, 5 Mar 2022 00:04 UTC

If I'm using the following code how would I modify it so that the date is only inserted when a specific word is put into a cell?

/**
* Creates a Date Stamp if a column is edited.
*/
//CORE VARIABLES
// The column you want to check if something is entered.
var COLUMNTOCHECK = 1;
// Where you want the date time stamp offset from the input location. [row, column]
var DATETIMELOCATION = [0,3];
// Sheet you are working on
var SHEETNAME = 'Sheet1'
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//checks that we're on the correct sheet.
if( sheet.getSheetName() == SHEETNAME ) {
var selectedCell = ss.getActiveCell();
//checks the column to ensure it is on the one we want to cause the date to appear.
if( selectedCell.getColumn() == COLUMNTOCHECK) {
var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);
dateTimeCell.setValue(new Date());
}
}
}

Re: Static Date Insertion Formula

<MPG.3c8dad821f3b01fd9899ad@news.eternal-september.org>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=268&group=microsoft.public.excel.misc#268

  copy link   Newsgroups: microsoft.public.excel.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: thiswill...@you.com (Philip Herlihy)
Newsgroups: microsoft.public.excel.misc
Subject: Re: Static Date Insertion Formula
Date: Sat, 5 Mar 2022 17:26:01 -0000
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <MPG.3c8dad821f3b01fd9899ad@news.eternal-september.org>
References: <572B2607-E7ED-4A45-AA5D-0917095FD8EE@microsoft.com> <483C5DC5-3514-4F35-A643-ABF003529C62@microsoft.com> <1D0EF067-D6A1-4410-9B5A-0EF5D663E8F7@microsoft.com> <92014F4D-7E6F-4E5E-97E5-124EBC2E07ED@microsoft.com> <8f59e925-d332-499d-ba1a-dab9d48536dcn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="fabdfa7091883b75b22d63c3b417606f";
logging-data="2219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vJAWcZT6NpMc4rtI/OuAnk/Qr35RadsQ="
User-Agent: MicroPlanet-Gravity/3.0.10 (GRC)
Cancel-Lock: sha1:ET9p3KsdLLSnjW5ZAkjcOvIv/ws=
 by: Philip Herlihy - Sat, 5 Mar 2022 17:26 UTC

In article <8f59e925-d332-499d-ba1a-dab9d48536dcn@googlegroups.com>,
jared.schmid@visitbicycleworld.com says...
>
> If I'm using the following code how would I modify it so that the date is only inserted when a specific word is put into a cell?
>
> /**
> * Creates a Date Stamp if a column is edited.
> */
>
> //CORE VARIABLES
> // The column you want to check if something is entered.
> var COLUMNTOCHECK = 1;
> // Where you want the date time stamp offset from the input location. [row, column]
> var DATETIMELOCATION = [0,3];
> // Sheet you are working on
> var SHEETNAME = 'Sheet1'
>
> function onEdit(e) {
> var ss = SpreadsheetApp.getActiveSpreadsheet();
> var sheet = ss.getActiveSheet();
> //checks that we're on the correct sheet.
> if( sheet.getSheetName() == SHEETNAME ) {
> var selectedCell = ss.getActiveCell();
> //checks the column to ensure it is on the one we want to cause the date to appear.
> if( selectedCell.getColumn() == COLUMNTOCHECK) {
> var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);
> dateTimeCell.setValue(new Date());
> }
> }
> }

Interesting puzzle. Rather than focus on the code you have here, I prefer to
stand back and work from the desired goal, which I presume is to keep a record
of the last change date of any cell - if the latest value matches some string.

Most of my VBA has been done in other applications than Excel, so no
guarantees!

Firstly, I see Events operate at the Worksheet level, rather than per cell or
range. So I'd put my code into the event handler for the "worksheet.change"
Event:

The standard event handler, always called "Worksheet_Change", returns a value
"Target", which is the range (one or more cells) whose change triggered the
Event.

These web pages explain how to do that:
https://www.thesmallman.com/vba-worksheet-change-events (nice video)
https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet.change
https://docs.microsoft.com/en-us/office/troubleshoot/excel/run-macro-cells-
change
https://www.extendoffice.com/documents/excel/3884-excel-monitor-cell-
changes.html
http://www.cpearson.com/excel/Events.aspx

You'd then look to see if the latest value of the cell or cells matches your
string of interest (lots of functions to play with to do that) and then take
whatever action you want. Personally, I'd want to consider commenting the cell
itself rather than writing to another cell - see this:
https://docs.microsoft.com/en-us/office/vba/api/excel.range.addcomment

I note your code relies on the ActiveCell: I'm not confident that this would
always be the changed cell. If you start editing a cell, and then click
elsewhere (or tab to next cell) your changes will be retained but the
ActiveCell would surely be the one you just entered? I can't find anything
online to say either way!

Hope that helps.
--

Phil, London


computers / microsoft.public.excel.misc / Re: Static Date Insertion Formula

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor