I've noticed a slight anomolae in Google Sheets v4 API when adding multiple sheets. When adding a sheet that refers to a non-existant sheet (yet created) when you go in and view the sheet once all are added the formula produces an error - even if the later sheet is in fact now present.
Steps to reproduce:
Add a sheet to a workbook that references in a formula 'Named Table'
Add a sheet called 'Named Table'
The formula in Sheet 1 will error. Go into the cell and hit return and the calculation refreshes (even though nothing has changed) and it will work fine.
Question: Can this refresh process be programatically triggered for Sheets API v4 ?
It can be triggered by the API today by doing the same thing the UI is doing -- read the value in the cell & apply an update to that cell with the same value.
Related
I would like to erase all the data of a sheet in a google sheet
via the googlet sheets APIs: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear
Unfortunately I can not select the id of my sheet.
I used the proposed method: POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetid}/values/{range}: clear
but it only removes the data from my first sheet.
How can I put the id of my other leaves in the method?
My google sheets ID
My first sheets in my google sheets
ID of my second sheets
My second sheets in my google sheets
From your reply, the request of "Method: spreadsheets.values.clear" is as follows.
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:clear
spreadsheetId : The spreadsheet the updates were applied to.
range: The range (in A1 notation) that was cleared. (If the request was for an unbounded range or a ranger larger than the bounds of the sheet, this will be the actual range that was cleared, bounded to the sheet's limits.)
In this case, it is not required to use the sheet ID. The sheet name is used.
From your showing images, it seems that the sheet names of your 1st and 2nd sheet are Feuille 1 and Feuille 2, respectively. For example, when you want to clear 2nd sheet of Feuille 2, please use the following request.
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Feuille%202:clear
Note:
For example, when you want to retrieve the sheet names from a Google Spreadsheet, you can use "Method: spreadsheets.get". Ref
Reference:
Method: spreadsheets.values.clear
We have created a workbook which use ActiveX objects and macros to perform multiple actions (calculations, changing values in cells, forcing mandatory fields before save, colour changes, lock and unlock, etc). There are 3 sheets:
Lists - where we set the values for comboboxes, run mandatory checks against cells and comboboxes, etc. this is VeryHidden to the user
Form - this is where the user will enter their data. it contains all of the ActiveX objects
Import - this is a formatted sheet which we can import to our database with expected formatting on values (i.e. "inches" instead of "in.H2O#60F", days converted to hours). this sheet is VeryHidden.
This workbook can be downloaded blank from our website and imported back into the database successfully.
What we want to do is download a pre-populated version where "Form" shows data from the database. To do this we are populating the Import sheet with the values (as they are already linked to the comboboxes we need to populate). i.e. ComboA on "Form" is linked to cell A4 on "Import".
We expected the comboboxes with linked cells to the update when we downloaded and opened the pre-populated workbook. When it did not we tried:
Sheets("Import").EnableCalculation = False
Sheets("Import").EnableCalculation = True
Application.Calculate
to force the row to "recalculate" and therefore trigger the linked cell to work as when we manually went into one of the linked cells and pressed enter (or F9) the associated combobox updated.
This was partially successful in that is populated around 1/3 of the comboboxes but not all of them. There does not seem to be an order or data type causing the issue (some Y/N update, others do not. comboboxes A-D will update, then E-G will not, then H will).
We tried Application.CalculateFull as well as:
setting the linkedcells to Dirty
only applying .Calculate to the range on the worksheet
only applying .Calculate to the row on the worksheet (as it is all in one row)
We can manually force each combobox to populate with it's linked cell however given the number of comboboxes and the fact there will be more workbooks like this to build this is not an ideal solution.
We know it is hitting the workbook_Open() event as we put in some MsgBox items and the couple custom populations we do (converting degF to F then pushing to combobox) and that is working fine.
If we open the download, save it (skipping the mandatory fields before save), then reopen it everything populates/selects correctly (which is all the more frustrating).
Any thoughts on why the downloaded version is not acting as expected would be much appreciated.
given the other posts I have seen and the follow up information requested I though more was better. there is a code snippet there - and we found a solution to the issue. needed to add Application.Calculation = xlCalculationAutomatic to the open event before the code provided above. thanks anyways
I am trying to reference a cell in the below formulaes. 'AUA Summary'!$D$9 . Each time the macro runs a new column D is inserted.
The Problem: When the column is inserted my reference moves to **
'AUA Summary'!$E$9. How do I get to reference 'AUA Summary'!$D$9 even if a new cell is inserted using VBA. My formuleas are below.
=IF(ROUND((SUM('BLL UTADS'!$D:$D)-'AUA Summary'!$D$9)+
(SUM('BLL UTADS'!$E:$E)-'AUA Summary'!$D$15),2)=0,"OK",
"Balances don't tie on BLL UTADS to AUA Summary Sheet")
=IF((SUM('BLL Prestige'!$D:$D)-'AUA Summary'!$D$10)+
(SUM('BLL Prestige'!$E:$E)-'AUA Summary'!$D$16)=0,"OK",
"Balances don't tie on BLL Prestige to AUA Summary Sheet")
=IF((ROUND('AUA Detail'!$D$9+'AUA Detail'!$D$23-'AUA
Summary'!$D$11,1)+ROUND('AUA Detail'!$D$15+'AUA Detail'!$D$29-'AUA
Summary'!$D$17,1))=0,"OK","Check the Totals tie")
The issue is on the 'AUA Summary' Tab the reference keeps changing. I have tried a VBA recorder , but i keep getting the same issue.
Each of these formuleas will be in a Cell.
You can use Indirect()
For example
'AUA Summary'!$D$9
can be written as
INDIRECT("'AUA Summary'!$D$9")
This way even when the columns move, it will refer to the same cell.
The other way is to use Index
For example D9 in Excel 2007+ can be written as INDEX(1:1048576,9,4) or INDEX(INDIRECT("1:" & ROWS(A:A)),9,4) for any version of Excel
Spent hours searching for any mention of this but no luck. Maybe someone here knows the answer. I developed a large application in excel. sheet1 receives data from a Com server that just places it there. This has been working for a long time with no problems.
I have sheet2 two with links from sheet 1 and formulas. Mostly I do all the processing in sheet1 change event because I got circular refernces when putting functions in a cell.
From yesterday, I have a problem that the cell in sheet 2 shows 0. When I go to the linked cell it has data. Sometimes numbers and sometimes text depending, but sheet 2 shows 0.
As well as the linked cells, I also screen scrape some data with a seperate process and place it sheet 3 to link across to other cells, so sheet2 will also contain links form this data. I spent today changing this so it places the data in directly in sheet1 instead of creating links. This is tedious and will cause other problems.
I checked options -> formulas. Right now it is set at max iterations 100; max change 100. I had reduced max iterations to stop some functions firing themselves recursively through the sheet change event. Now I raised it back to 100.
I deleted all the data saved the sheet started again and the same thing happened again.
e.g. sheet1 cell "A1" has a value of 10
sheet2 cell a1 has a formula of ='sheet1'!A1
sheet 2 cell A1 is showing 0
when I look in the formula bar I see the formula
This data was damaged down to row 42 the last row that had held data. below that the conditional formatting was the correct color even though the formulas looked identical and i could see nothing wrong to explain it, I dragged the formula from 44 upwards again and everything worked, but bizarrely, when I copied from sheet1 cells 1 to 44 and pasted a link back in, I still got 0.
When I run the system and the COM erver delivers a load and the change event fires etc, I end up back with the same problem.
Now when I add a new sheet and paste my links from sheet1 into this, it works as it should.
Right now after my attempts to fix it. All sheet1 and sheet2 columns are formatted general though previousy I had one column text and some others number. I can't control the format of sheet1 because excel just adapts to the data it receives regardless what I do.
I also keep checkng for application.enableevents and this is not the problem nor is worksheet calculate and in the options I have automatic claculation set
The only other routine running under sheet change in sheet 2 is a tidyup that clears out old data after the COM server has delivered a smaller number of rows.
It copies default data from unused cells in the sheet. I placed the right formatting and default such as blank or 0 depending on what is required. This has not in the past caused any issues and I cant see what it might do, though previously when I just tried puttng "" in the cells to be cleared that did cause nasty excel erros. but not now.
Does anyone have any ideas?
I don't know if this is still relevant, but I had the same issue and came here searching for an answer.
In my case, I realized the cell I was trying to copy was a merged cell (i.e. it provided a range) the formula was [='Sheet1'!B10:N10] and the result was 0 and not the text I wanted. so I changed the formula to ='USA-CA'!B10 and it worked.
hope this is helpful to someone else.
This little routine fixes it.
Sub fixformulas()
'fix formulas broken by excel for some reason
Cells.Replace What:="=", Replacement:="=", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
End Sub
All I can work out is that when excel copies the formulas and puts them back in place it corrupts the equals sign. Everything else is fine but as oon as I replace this the lights go on.
I'd rather know how to prevent it, but I hope nobody else suffers like I have.
I am building a small piece of VBA code to update the pivot table automatically so that my chart gets updated. After recording the code, I created stored it in the vb script of the sheet.
Here is my code:
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
I do not want to show the sheet containing the pivot table. So I hide the sheet, and then the code fails to work.
Try changing ActiveSheet to Worksheets("WorksheetName")
So you'd have
Worksheets("WorksheetName").PivotTables("PivotTable2").PivotCache.Refresh
Using ActiveSheet means it performs it on the sheet that is currently selected, last I checked you can't have a hidden sheet selected ;)