Paste values disabled in Excel when recording a macro - excel

I started to record a macro, added a name and inserted the formula =NOW( ) in a cell.
After selecting and copying this cell, I want to convert the formula to its value by "Paste Values" in Home->Clipboard->Paste menu.
The Paste Values submenu command is disabled, and the Record Macro button is disabled. This results in being unable to stop recording the macro.
How can this be solved?

I wasn't able to replicate this behaviour so not sure why you are unable to stop recording your macro but ...
I presume you are trying to have the cell contents contain the time / date at a fixed point and not change every time you open the spreadsheet or recalculate? If so, a line such as:
activesheet.range("A1").value = now()
This removes the need to faff about with copying and pasting values.
HTH

Related

If Vlookup formula can remain there even after running a Macro

I have made a Data Entry form in which i have recorded a macro Using "Use Relative Reference" from developers tab.
I have also added vlookup formula so that if a certain value or word is selected many of the fields being pulled or appears automatically.
I have created a button named as "Save Data" and have recorded a macro in it
After adding all the values (few values manually, few values I pull via Vlookup) whenever i press the button "Save Data" it moves the all values from data entry form to another Main Worksheet.
However the problem is whenever i press the button it also removes the formula of Vlookup and I have to either paste Vlookup formula again or add the values manually. the formula of Vlookup is
=VLOOKUP(C12,Functions!F$2:J$20,3,0)
Can anyone suggest if even after pressing the button and after moving the data the formula should remain there and i do not have to put them manually again and again

How to modify the value of a formula with a macro in an excel?

I have an excel file that has different formulas. What I am looking for is to modify only one element of that formula since due to the process that I am working on, the formula could change, but the period (eg 202112) is a field that must always exist, so I think I could not generate the formulas with a macro, since these are modified by another user. Is it possible to add a variable to the formula and update/change the value by pressing a button?
The following table is only to explain what I need, it is too simple, but it is not to enter the long formulas.
I would like to assign a macro to the button so that when pressing it the value of the variable "Period" is updated, for example 202112
Without using macro you should change the excel recalculates settings;
-In Excel, click the Microsoft Office Button, click Excel Options, and then click the Formulas category and in the Calculation options section, under Workbook Calculation, click Manual and uncheck the checkbox.
Use this formula for your Ids+Period column;
=B2&C2&TEXT(TODAY(),"yyyymm")
To update your cell formula (or date). You should click the cell and after that command line and click enter. Done!

How to copy any cell value by just clicking on it then press the macro button it will paste the value in another cell?

Here are the details:
There are two sheets in an Excel macro-enabled file. In sheet-1, I have a column of all unique values. I want to click on any of those cells and then press the macro button which says "Filter", it will copy the value of the clicked cell and go to sheet-2 and paste that value in the filter search in a particular column. That's it. I tried recording the macro, thinking it will understand my input actions like click to select the cell, ctrl+c, ctrl+v. It is actually understanding those actions but it is copying and searching only the cell value that I have clicked while recording the macro. So when I click on another cell and then the macro button, it is searching for that only value that I clicked during the recording. I want it to be more dynamic. Like if I click on any cell, it should copy that particular value in paste it in the filter search in sheet-2.
Do you want to use the value as an autofilter?
If so, I guess you should have a row like the following in your recorded macro:
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:= "something"
Remove everything else from this recording, and change the row to:
Sheets(2).ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=Selection.Value
But using your table name and the correct sheet name or index, and field.
The point is, change the value after Criteria1:= to Selection.Value and refer to a specific sheet, not ActiveSheet.
Mind you that this is a minimal effort approach. It doesn't handle multiple selections. I've found that if there is a range larger than one cell, it picks the "last" cell as the filter value.

How do i create a Power Query custom column AND insert an excel formula into each cell of the final table?

I want that when the table is created there will be a fully functioning excel formula. If I try with "... each "=[#[Prog.]]" there will insert only the text not the formula.
P.S.: I'm new to this so, excuse me if this is basic.
From what I understand, you can create Excel formulas in Power Query and pass those to your Excel worksheet but the worksheet won't automatically recalculate. This earlier post addressed the same thing.
I tried this out by creating a table with two columns: "Column1" and "Column2", with the numbers 1 & 2 in each, respectively. Then, I loaded the table into Power Query and created a new column, "Custom", with the formula, "=" & Text.From([Column1]) & "+" & Text.From([Column2]). (To be clear, the = here is not the = that is already populated when the new column dialog box pops up, it's additional.) Anyhow, I got this table from that formula:
Then, when I clicked "Close and Load," my Excel worksheet was loaded with this:
Notice it looks just like text, but in the formula bar, it looks like this:
Notice there isn't a ' before the =, so it's a formula. If it were just text, it would be '=1+2 instead of =1+2.
Since the cell doesn't automatically recalculate, I had to click the cell I wanted to update, and then click in the formula bar and then press enter. That gave me this:
I tried to use F9 to manually recalculate, but it did not work.
Also... Every time I refreshed my query, my worksheet was set back to just the text-looking formula (i.e., =1+2) and I had to re-recalculate manually. That would be a real pain to have to do that for a lot of cells each time you refresh your query.
#Umut K posted a VBA-based workaround to trigger refresh all in the earlier post, but I think what you are asking to do might be more trouble than you're looking for.
The above answers are correct that the formulas do not automatically recalculate, even though they are in the cell correctly. A workaround/trick that I found was to use -Find/Replace to trigger a recalculate on every cell in one step. Go to one of the cells with the formula; to copy the entire formula. to open the Find/Replace dialog. in both the Find What and Replace With boxes in the dialog. Click on Replace All. All the cells except the one you are in will recalculate. Then, exit the cell you are in, and it will also recalculate.
It seems stupid, but it works.

excel batch pasting formulas

I have a list of documents that I want to paste relative links to in Excel. I converted the list to a list of Excel formulas that look like
=HYPERLINK(".\docs\123abc\1.doc","1.doc")
=HYPERLINK(".\docs\456abc\1.doc","1.doc")
However when I paste this in Excel it will paste the text for the formula and not actually make it a formula. I have tried creating a macro to set each cell's FormulaR1C1 value as the value from the text in the cell and that didn't fix it. As well I have tried to copy and paste special as forumla and that did nothing either.
If I type in each formula by hand instead of copying and pasting them it works great, however the list of forumlas I have is a couple hundred and I would prefer not to have to type each one in by hand. Does anyone have any experience with this or suggestions on getting the forumla to register?
Before pasting the formulas,
Select all cells in worksheet
Right click and select "Format Cells..."
In the Number tab page, select General and click OK button.
Paste your formulas list.

Resources