ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Formula Updating Problem (https://www.excelbanter.com/excel-programming/300764-macro-formula-updating-problem.html)

tim

Macro Formula Updating Problem
 
In a workbook I have 2 sheets. I use a macro to transfer the data from acolumn in sheet 1 to a row in sheet 2. The data that is transfered to sheet 2 is a list of names and info for each one. What happens i
1) I run a macro to setup the sheets how I want them
a) This macro sets up sheet 1 with the info i want in sheet 1 and uses that same info as headings on sheet 2
b) The macro also sets up on sheet 1 a formula to count how many names there are on sheet 2. (I think this is where
the problem is.)
2) I use a second macro to take the data that the user inputs on sheet 1 and transfers it to sheet 2. The data moved by this
is what i want to count
The reason I need to count the number of names is that when I use the second macro, I needed a way to specify the next blank row (i.e. 2 rows are for headings, and then if there is info in a row , then go to row #ofnames+2(headings)+1(for the next row)
Here is the problem
The formula that I use to calculate the number of names currently is =(CountA('Sheet 2'!A:A))-2. This should return 0, because there A1 and A2 are full (they are the headings) and there is no more info. If I manually input the formula into a cell it works fine. However, when the macro initially inputs the formula it gives -1 as the answer. Then if I add names to sheet 2 it stays at -1, but the manually entered formula counts properly

What can I do to fix this? Or is there a better way to do what I want?


All times are GMT +1. The time now is 07:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com