+ Reply to Thread
Results 1 to 5 of 5

Fill data series or resize range not working on large blank ranges

Hybrid View

Gareth Allan Fill data series or resize... 11-17-2020, 05:56 AM
Sintek Re: Fill data series or... 11-20-2020, 05:56 AM
Gareth Allan Re: Fill data series or... 11-25-2020, 08:09 AM
Sintek Re: Fill data series or... 11-25-2020, 08:15 AM
Gareth Allan Re: Fill data series or... 11-25-2020, 08:20 AM
  1. #1
    Registered User
    Join Date
    11-16-2020
    Location
    Aberdeen
    MS-Off Ver
    Excel 2016
    Posts
    5

    Fill data series or resize range not working on large blank ranges

    Morning

    I have an inherited macro, that occasionally does not behave as intended, when trying to fill a data series between two column values - sometimes when there is a large number of blank cells/rows between the two points, it doesn't fill correctly.

    So it has a user entered data fields on the first 4 columns - the fourth column is a marker used to indicate certain triggers IRL and used as targets in this macro

    so in this example, it has an 's' marker that the macro looks for to determine the start and end of the data series fill - note that there may be several different markers throughout the data series, each 'pair' it calculates a new series for, and fills between. it also uses the first and last cells by default.

    So I have stripped some other stuff out of this to redact it slightly, but the example shows a failure state, when running the 'get values' macro button:
    1) it is able to fill a data series in column L between the 's' tags at row 2 and 21
    2) it fails to enter a data series between the next set, between row 21 and row 18116

    I can manually create a FILL / SERIES / COLUMN / LINEAR / TREND between these samples

    You can also step through the 'get_overwrite_Original' macro, and see that it is calculating the correct step value (I think)

    So, the macro works when there is a small number of cells to range over, but fails if this is too large - I have been unable to find the information about limiting the resize range command it seems to use - any ideas?

    Example excel, with sample data and macro attached - click clear calculated field, then get values to see in action

    Gareth
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Fill data series or resize range not working on large blank ranges

    Hi Gareth

    Welcome to the Forum...

    Try this ...Output col L
    Option Explicit
    Option Compare Text
    Sub sintekJ3v16()
    Dim Data, Valu As Double, i As Long, rw As Long, x As Long
    rw = 2
    With Cells(1).CurrentRegion
        Data = .Value
        For i = 2 To UBound(Data)
            If Data(i, 4) = "s" Then
                Range("L" & i) = Data(i, 2)
                If i > 2 Then
                    x = Application.CountBlank(Range("L2:L" & i)) + 1
                    Valu = (1 / x) * -1
                    Range("L" & rw).Resize(x).DataSeries , , , Valu, Data(i, 2)
                    rw = i
                End If
            End If
        Next i
    End With
    End Sub
    Last edited by Sintek; 11-20-2020 at 06:01 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    11-16-2020
    Location
    Aberdeen
    MS-Off Ver
    Excel 2016
    Posts
    5

    Re: Fill data series or resize range not working on large blank ranges

    Afternoon

    Unfortunately the code did not work for me, in my situation

    However, a bit more digging found a different way to do it:

    'fill data series column
    Application.ScreenUpdating = True
    
    Dim sht As Worksheet
    Dim firstCell As Range, lastCell As Range
    Dim fillRange As Range, cell As Range
    Dim lastRow As Long, firstRow As Long
    Dim fillCol As String
    Set sht = ThisWorkbook.Worksheets("raw data")
    lastRow = lr 'the row of the last cell you want to fill
    firstRow = 2 'the row where your data begins
    fillCol = "L" 'the column to be filled
    
    
    Set firstCell = sht.Range(fillCol & firstRow)
    While firstCell.Row <> lastRow
        If firstCell.End(xlDown).Row > lastRow Then
            Set lastCell = sht.Range(fillCol & lastRow)
        Else
            Set lastCell = firstCell.End(xlDown)
        End If
        sht.Range(firstCell, lastCell).DataSeries Type:=xlLinear, Trend:=True
        Set firstCell = lastCell
    Wend
    in this example, my last line is LR in initial macro,or could be entered as a manual value.

    the above macro used a CTRL + Down arrow type 'search' to jump between the values i want to fill between. I therefore had to change the format of my 'fill' column after a paste, and while its not the most elegant solution, I used a record macros, text to columns code to do this:
    Selection.TextToColumns Destination:=Range("L2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 1), TrailingMinusNumbers:=True

    always fun how there are so many different ways to do things - anyways thanks for the help

    Gareth

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Fill data series or resize range not working on large blank ranges

    Unfortunately the code did not work for me, in my situation
    Strange...Worked perfectly with sample upload...Gave exact results...Am guessing your actual file is different...

  5. #5
    Registered User
    Join Date
    11-16-2020
    Location
    Aberdeen
    MS-Off Ver
    Excel 2016
    Posts
    5

    Re: Fill data series or resize range not working on large blank ranges

    well the example I was using was heavily redacted...

    it had more triggers than just the 's', and needed the first and last values highlighted as well.

    as usual when I deal with programmers, it makes perfect sense in my head when I explain it the first time, but I always need to add stuff i missed out

    Away to dig out my other partially broken files now

    Gareth

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Fill Series not working
    By pschristmas in forum Excel General
    Replies: 7
    Last Post: 01-19-2021, 09:28 AM
  2. [SOLVED] Need to fill date series (monthly) in a large document
    By raselkhl in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 10-15-2019, 10:23 PM
  3. [SOLVED] Multiple Dynamic Named Ranges w/ Blank Cells Auto Update on Resize
    By finkbee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2019, 05:00 AM
  4. [SOLVED] Insert blank rows in a large data series
    By bananacitizen in forum Excel General
    Replies: 6
    Last Post: 07-19-2019, 08:03 AM
  5. [SOLVED] VBA code to fill blank cells ranges
    By Nienaber in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2015, 11:40 PM
  6. How to fill in Blank Cells with series?
    By floridagunner in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-21-2007, 03:32 AM
  7. Range resize not working
    By Ray Batig in forum Excel General
    Replies: 5
    Last Post: 02-26-2006, 05:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1