Excel CountA not correct when opening workbook - excel

I have a .xlsm workbook used as a template (I am using Excel 2010) to create a workbook when users wish to download via a website.
A copy of the template is made when a download is attempted and values are written into a lookup tab in the copy (there are 2 columns: name and id) via .NET code. This part works great.
There is a second tab that uses a COUNTA formula to determine how many rows of data are populated in one of the columns.
My problem is that the COUNTA formula is showing a value of 0 instead of the correct value when the workbook is opened and macros have run. If I were to manually enter the field and refresh the value the value will be correct.
The formula is:
=COUNTA(LOOKUP!A2:A1000)
Why doesn't this work and what can be done to make it work?

Hello Here is a pretty fast way to count all of the Cells in A
Sub btnCount()
Range("A1", Range("A1").End(xlDown)).Select
MsgBox Selection.Count
End Sub

Related

Excel cell is magically populated with formula after another cell gets data entered

Some mysterious behavior within a simple worksheet (Excel 2013 - Win7, but also continues if workbook is opened on Excel 2019 - Win10):
Cells in column "A" are getting populated with a formula after I enter a number in cell of column "C".
For example:
When I enter the number 123456 in C23, the following is automatically entered into a previously blank A23: =HYPERLINK("http://gigapan.com/gigapans/"&C23,C23) which is what I want, but how is it happening automatically? There are NO conditional formattings (that I can find), NO Worksheet_Change VBA subs running (NO VBA code at all for this workbook). The result is what I want, but it is driving me crazy not knowing how it got set up this way!!! Took the xlsx file to another computer with no Personal.xlsb to interfere and same behavior. Suggestions?
Excel example screenshot...
This is normal behaviour, controlled by the option Advanced > Extend data range formats and formulas. Described at https://support.microsoft.com/en-us/office/advanced-options-33244b32-fe79-4579-91a6-48b3be0377c4

Formulas become unresponsive to changed value inputs to referenced cells

The question closest to mine did not return a satisfactory answer.
Inserted formula with cell reference does not recognize new input
In a particular macro-enabled workbook, macro-generated formulas do not change output values when data in referenced cells is changed. For instance, I can enter some numbers in referenced cells and the formula-containing cell will show the calculated number, but those numbers will not change when changing the data in the references. Manually typed formulas in the same workbook show the same behavior regardless of being in or outside range objects or in non-macro generated worksheets within this workbook. It doesn't seem to be specific to any particular formula.
I checked that the cells are formatted as numbers and that the formulas are valid. Formulas still appear in the cells after computing values.
Reloading the same workbook without macro-enabling shows the formulas working correctly.
In another macro-enabled workbook no problem is observed.
I checked property settings in the VBA editor and found no differences between them.
It seems like something is going on related to macro-enabling and not any particular code that is causing formulas to become unresponsive, but I am stumped as to what that could be.
Here is the formula in which I noticed the problem:
in "=d4:d21" the array formula "{=IF(ISNUMBER(C4:C21), C4:C21/C3, "0")}"
Even with a simple formula placed anywhere on the sheet like "=average(f4:f6)", this problem occurs.
I think creating the macro containing these lines of code is when the issue started, but they are not specific to it:
Sub CreateDataSheet()
Sheets.Add After:=ActiveSheet
Range("d4:d21").Select
Selection.FormulaArray = _
"=IF(ISNUMBER(RC[-1]:R[17]C[-1], RC[-1]:R[17]C[-1]/R[-1]C[-1], ""0"")"
End Sub
How can I get these formulas to work again?
The calculations in the workbook were set to 'manual' and I changed it to 'automatic'. The formulas work now.

Changing sheet names using a formula

I have an Excel workbook with various tabs on it.
In Sheet 1 (named: ‘Pricing Calculator’) you can input various data and it calculates a price.
Sheet 2 (named: ‘Final Copy’) is basically the same as Sheet 1, however it is not used for inputting data. So in this sheet cell A1=’Pricing Calculator’!A1 etc. for most of the sheet.
However, sometimes Sheet 1 (‘Pricing Calculator’) is copied and that and the copied sheets renamed to ‘Option 1’, ‘Option 2’, ‘Option 3’ etc. Sheet 2 (‘Final Copy’) only needs to use information out of one of these sheets, but which one will depend on which option is chosen.
I have tried adding a cell into Sheet 2 (say it was A30) where you can type in exactly the name of the sheet to get the data from, and changing the cells to =’A30’!A1 etc, but this doesn’t work because it is looking for a sheet called ‘A30’.
It works by clicking ‘replace’ and changing everything that says ‘Pricing Calculator’ to ‘Option 2’ or whatever. But I have got to password protect all of the sheets so that no one can change them, therefore I can’t use the replace method!
Does anyone have any ideas as to what I could do? I would prefer to avoid using macros or VBA if possible.
You could use INDIRECT() for this.
=INDIRECT("'" & A30 & "'!A1")

How can I make my excel formulas calculate after values have been added programatically

I have a .net program that updates values in an excel sheet programmatically using an OLEDB connection.
my excel sheet has some simple SUM formulas that sum the values that are programmatically updated. The problem is that since the values are updated while the excel sheet is closed my formulas do not calculate when the sheet is opened. When I press calculate sheet button the formulas are still not executed (because excel does not recognize that the new values have been added, possibly?). The only way I can get them to execute is if I click on the cell holding the formula (As if to modify the formula) then press enter(making excel reevaluate the cells). I have calculation option set to automatic and my data types are correct (general for the formulas and number for the number values). Is there any way I can make the spreadsheet calculate the formulas when I open it?
Try pressing ctrl+alt+f9 which should force a full calculation and not just a recalculation (like the calculate button does) that looks at cells that have changed.
More info on calculation material can be found here.
For vba I believe it is
Application.CalculateFull
Maybe this will work
Private Sub Workbook_Open()
Worksheets(1).Calculate
End Sub
Just in case someone runs into this problem: To do a full recalculation in vba you can use Application.CalculateFullRebuild to force a full calculation.

Automate data transfer between workbooks in Excel

I admit to not being very technical and my limit up to now has been using paste links to connect data between sheets. I now have a requirement I cannot figure out.
I have 2 workbooks I wish to automate sharing data between.
Workbook 1 contains multiple rows of data manually entered.
I need a button against each row so when it is pressed data from certain cells on that row in Workbook 1 are transferred to cells within a worksheet in workbook 2
I would be very grateful for any guidance on how to achieve this.
Many thanks!
Though you can deploy VBA to achieve this, but the same is also possible with simple formula like.
=[1.xlsx]Sheet1!$A$1
Lets say you have two workbooks 1.xlsx and 2.xlsx and you want sheet1/column A1 value from 1.xlsx to be auto populated in sheet1/column A1 in 2.xlsx, you can simply link it with a formula like =[1.xlsx]Sheet1!$A$1 in second workbook 2.xlsx.
So as soon as some entry is done in first cell, second cell is auto populated
However if you are looking only for vba solution do write back

Resources