CodexBloom - Programming Q&A Platform

Excel: How to auto-fill a series based on a non-linear trend without using a formula?

πŸ‘€ Views: 96 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-01
excel vba autofill

I'm building a feature where I've been working on this all day and I've been banging my head against this for hours. I've looked through the documentation and I'm still confused about I'm working on a project and hit a roadblock. I'm working on an Excel sheet where I need to auto-fill a series of values based on a non-linear trend but need to seem to find a straightforward way to do this without resorting to complicated formulas. The values in my series are supposed to follow a quadratic pattern, but I'm trying to avoid using complex formulas for each cell because I want to maintain performance in a large dataset. I've tried using the AutoFill handle by selecting the first few cells in the series, but it just replicates the values without following the intended trend. I also looked into using a scatter plot to visualize the trend, but I couldn't find a method to extrapolate those values to fill the cells automatically. Here's a simplified version of what I have in my sheet: | A | B | |-------|-------| | 1 | 1 | | 2 | 4 | | 3 | 9 | | 4 | | | 5 | | I want cells B4 and B5 to automatically fill with 16 and 25, respectively, without manually entering a formula in each cell. I've also checked whether there are any settings in Excel 365 that might help, but I’m hitting a wall. Is there an efficient way to achieve this? If it requires using VBA, I'd be open to that as well. Here’s an attempt I made with VBA, but I encountered issues when trying to set the values: ```vba Sub FillQuadraticSeries() Dim i As Integer For i = 1 To 5 Cells(i + 1, 2).Value = i ^ 2 Next i End Sub ``` When I run this, it fills the cells correctly, but it’s not quite what I want since I would prefer it to adapt within rows that also contain data. Any insights on how to implement this more effectively would be appreciated! This is part of a larger API I'm building. How would you solve this? This is part of a larger API I'm building. Any help would be greatly appreciated! I'm developing on CentOS with Vba. What are your experiences with this?