Hello,
can anyone tell me how I can fill out the cells of a column with a formula (please bear with me if I make any mistakes, English is not my native language. Thanks)
I have a table with thousands of data sets. The last 3 columns X Y Z are filled with formulas.
The problem is that every recalculation requires a few seconds. So, my idea was to write the formula only in the first row in the respective colums and fill every single cell by VBA one by one. The formula in the respective previous cell should be converted into value. I'm not sure but I think the less formula there are in the Sheet the faster it works.
After that the second, and finally the last column should be filled like this.
Is there any solucion for my problem?
I thought to do it with For...Next but I didn't manage it.
By the way, I am not really new in VBA and I find my way in the Editor and I am familiar with the syntax. But I can't write my own code yet.
Many thanks for your help
conf
Try this.
Sub d() Dim LR& LR = Cells(Rows.Count, 1).End(xlUp).Row Cells(1, 24).Resize(LR).Formula = "YourFormula" 'Your formula for x column Cells(1, 25).Resize(LR).Formula = "YourFormula" 'Your formula for y column Cells(1, 26).Resize(LR).Formula = "YourFormula" 'Your formula for z column Range("X1:Z" & LR).Value = Range("X1:Z" & LR).Value End Sub
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
I can't see how using VBA would be quicker. Switch Calculation to manual, then re-calculate only when you need to
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Hello JapanDave,
thanks for your reply. It works excellently.
But unfortunately this is not what I was looking for. I wanted to caculate every cell individually because the Array Formula require some time to calculate each time when it starts calculating.
With your code it takes the same time as I would fill it manually.
Do you have any further idea?
Thank you for your help!
conf
Hello Roy,
I'm not sure but I think it would be faster if there is only one cell with a formula inside. The results in the colums of the respective row depend on each other.
I can't upload it, the data are quite sensitiv.
Thanks for your reply.
conf
Ah, I forgot to mention that sometimes the application hang during calculation. I think this happens because of the CPU-intensive formula.
Post a workbook if you can?
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
Here you are, it's a simple copy of my sheet. Imagina how long it will work if you have thousands of rows and a plenty of columns to calculate.
llThat number of array formulas will be slow. You can switch calculation to manual, then when necessary just calculate a specific cell or range or range of cells
Cells(1, 1).Calculate
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thanks Roy,
I have to go on looking for another way. Thanks all for your effort!
Have a nice day!
conf
Why don't you simply sort your sheet ? first A, second B, third D ?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks