updating a part/the date of the URL in excel - excel

Basically, I haven't done much of excel formulation so this is new to me. I have an excel file which has a few hundreds of URL in it. now, most of these URL's are a search from different websites which include the dates in them. for example:
https://www.ft.com/search?q=investment&dateTo=2018-11-21&dateFrom=2018-11-21&sort=date
so the q=investment is what I'm searching which is static but the part To=2018-11-21&dateFrom=2018-11-21 depends on the date of everytime I open the file. I wonder if there is a way to formulate this URL so everytime I open the file, the dateTo=2018-11-21, and dateFrom=2018-11-21 gets updated by itself to todays date?

Let's assume the original URLs are in column B, and you put today's date =TODAY() in cell A1, you then put the following formula in cell C1 :
=SUBSTITUTE(B1;"2018-11-21";TEXT($A$1;"yyyy-mm-dd"))
And copy down as far as needed.
I hard coded the "2018-11-21" old date in the formula, but it would of course be easier to re-use if you put the old date in eg. A2 as a text string (very important, not as a date!)
If you want to have hyperlinks as output, just wrap with HYPERLINK() function:
=HYPERLINK(SUBSTITUTE(B1;"2018-11-21";TEXT($A$1;"yyyy-mm-dd")))

Related

excel format generated date (not hardcoded date)

I'm using closedxml to generate a excel file.
I'm mapping the cells directly in excel by creating a named range and inside of it reaching the items in the range by {{item.property}}, the range collection is added like a variable in the code.
The item I'm using has a Year property and a month property, the mapping in that excel cell is: {{item.Yr}}/{{item.Mon}}.
I would like Excel to format the value in the cell to mmm-yyyy (Jan-2020). Which it does if I directly write a date in the cell in Excel and presses Enter, but that's not what I want, I want it to format my generated value.
I've tried using the functions like =TEXT(date,format) or =DATEVALUE("1/1/2015").
But the problem is that I can't write directly "1/1/2015", I need to write something like DATEVALUE(1/{{item.Mon}}/{{item.Yr}} but Excel syntax doesn't allow this. Ofcourse I've also tried just the "format cell" to date on the cell, but doesn't work (only if I directly type a date and presses Enter)
I'm sorry for my crappy explanation. I hope someone understands what I mean and what I want to accomplish.
SOLVED
After 2 days banging my head against the wall, I found that If a variable is used in a formula, it needs to be escaped with "&" at the beginning:
&=Date({{item.Yr}},{{item.Mon}},1).

Excel force date to NOT change

The spreadsheet I am working on involves well over 100 cells, each with (possibly unique) dates, however for simplicity we will say that I have just 2 cells to work with, A1 and B1.
In A1 I want to enter data (could be text, or a number) ONE time...let's say on Monday.
I want to use something like an "IF" statement in B1:
(If A1 > "" then B1 = date (of data entry)
I want this date to be static (non-changing); in other words, I don't want that date to update on next Friday when I open the file to work in it again.
"Now" always updates. "Today" always updates. I do not want the date to keep changing to the current date, and I don't want to enter a date in the associated cell every time I enter data.
I'm really not sure this is possible using the standard Excel functions, but maybe someone else has an idea...? I've considered using VBA, but I'm not sure that's the best way to go either. TIA!
From Google:
Insert a static date or time into an Excel cell:
On a worksheet, select the cell into which you want to insert the current date or time.
Do one of the following: To insert the current date, press Ctrl+; (semi-colon). To insert the current time, press Ctrl+Shift+; (semi-colon).

Alter file path based on cell reference

A short explanation; I have a large amount of reports in one folder, and they are all formatted the exact same way every time, except for the date in the file name (ex. Out of Stock Report WE 04.20.16.xlsx). In the workbook where I have my formula, I'm referencing a cell that has a date in it, and then using that date (DT$3 reference is a date) as an input for the last part of the file path, so that it goes to the correct file and looks up the file. I don't need any actual index/match or lookup formula, because these reports are all formatted the exact same way, so the needed value is always in the same cell on the same worksheet. Here is my formula that I'm getting a #REF error on:
='\\dhqshareddata\data\Supply_Chain\Planning\Strategic Planning - Forecasting\Out of Stock\All Reports\[Out of Stock Report WE "&TEXT(DT$3, ("MM.DD.YY"))&".xlsx]Category Report'!$C$5
This should be simple but I can't get it to work. Additionally, an indirect function won't do me any good because I'll have to open every single report and copy/paste values, for hundreds of reports.

Excel cell reference to other workbook using previous date for name

I need to reference data in my current worksheet (a daily log) to the previous day log (to show past day data).
I can do this in a fixed format using a direct reference to the other workbook. However I would really like to have it automatically reference cells in the previous day log. Thankfully the file names are formatted nicely "2016 01 January.xlsm" so referencing them using a formula shouldn't be hard.
I know I can build cell value that shows the previous day name using:
=text(today()-1, "yyyy dd Mmmm") & ".xlsm"
However, when I attempt to use this within the cell that should reference this sheet it seems my concatenation is broken in:
='[TEXT(TODAY()-1, "yyyy dd Mmmm") & ".xlsm"]Readings'!$J$14
I could easily debug the concatenation in Matlab, but sadly I'm not in that environment and I don't seem to understand how Excel works as well as I should.
Thanks in advance!
Ben
You simply need to prepend your formula with the INDIRECT command. INDIRECT tells excel that you are not explicitly referring to a particular location, but that you want to dynamically calculate a location, and then refer to that calculated spot. Assuming your file names are correct, this should be as easy as:
=INDIRECT(TEXT(TODAY()-1, "'\[yyyy dd mmmm") & ".xlsm]Readings'!J14")
To test out that it creates the file names correctly, consider putting the concatenation formula in a different cell, and then referring to that cell with INDIRECT. This will confirm for you that you aren't mispelling something etc.
*Edited as highlighted by Jeeped, to now properly calculate the file name instead of hardcoding as an explicit string of text.

Excel always change my data to date when copy a html sheet to it

I copy a sheet from html page.Because I need the sheet structure,the "paste as text" selection is no use here.
The data will be like this
2/3 3/4
1012/2332 332/665
when paste to excel
2/3/2012 3/4/2012
1012/2332 332/665
the data cannot be parsed to date form is safe while those which can will be changed and cannot be changed back in format cell.
How to disable this feature of excel,really annoying.
This is an obnoxious problem. Have you tried setting the cell format to Text before pasting as text? this works for me in 2003. I'm afraid simply doing one or the other is not enough, and the order is important.
If this works (and you need to do this frequently or regularly), you can set up a custom macro (e.g. CTRL-SHIFT-P, etc.) to set the format and do the paste all in one motion.
EDIT:
For the record, here is what the different paste methods produced for "2/3":
Paste (normal) 3-Feb
TXT Format->Paste 3-Feb
Paste->TXT Format 40942
Paste UNI 3-Feb
*TXT Format->Paste UNI 2/3
Paste UNI->TXT Format 40942
Paste TXT 3-Feb
*TXT Format->Paste TXT 2/3
Paste TXT->TXT Formar 40942
Up until recently (2/27/2013) the Excel data import of the bank account text file information handled the date field of the text file correctly. It isn't clear to me why this changed, but it lead to my looking here for a solution.
I'd like to propose to you a different solution than above...
copy the offending dates to a separate excel sheet
use the Mid function ( mid(string, start, number of chars) to extract each date component to
a separate column in the same row (Look at columns B, C, and D
in the next column use the Date function ( date(yr, month, day) to convert the date components
from the prior three columns into something excel will deign to recognize as a date (remember,
computers are basically stupid, and Microsoft programs are about the contrariest things on the
planet!)
PASTE SPECIAL the values from your date column back to your worksheet
VOILA! You have fixed a problem that you should NEVER have had in the first place.
I tried to paste the spreadsheet here (and also by hand typing, but this display collapses repeating characters. Suffice to say it looks like this...
02/27/2013 02 27 2013 02/27/2013
original mm dd yyyy value ms recognizes as a date which you can paste by value back to spreadsheet
the formulas for those not familiar with Excel...
un-date from worksheet in column at (excel sees as a string...not a number!)
for month: mid(a1,1,2) (take the thing in column a1, start at the 1st character, and grab two chars)
for day: mid(a1,4, 2) (take the same thing from column a1, grab the two chars starting at the 4th)
for year: mid(a1,7,4) ...
making it a date: you now have month in column b1, day in column c1, and year in column d1, so
in column e1 you say: date(d1, b1, c1), and then you see the same date as shown in column a1, however, this will now be recognized by Excel as a date! Copy this and PASTE SPECIAL>Value to the column in your original worksheet and it will respond.
I had looked in the original column for a ' character which denotes treat this value as text only, but I hadn't found one. I do not know why Excel has become pesky like this, but I have come to expect this type of frustrating and annoying behavior from Microsoft programs. Yes, I do still buy the darn things, but often choose open source code when I can because of these "features".
Good luck.
I just came across this problem and found a really good solution. Here are my steps:
Copy and paste so that you can work out the area to be selected.
Delete the contents of the cells
Change the formatting to TEXT
re-paste but use the paste button in the menu bar and choose 'Match Destination formatting'.
This works like a dream! :)

Resources