Results 1 to 9 of 9

How to make a formula move down one to a new row each.

Threaded View

  1. #1
    Registered User
    Join Date
    10-12-2015
    Location
    Vidalia, Ga
    MS-Off Ver
    2010
    Posts
    9

    How to make a formula move down one to a new row each.

    I have a "For" Loop that runs to help me in a scheduling program. Each 'For' until a specified Qty is reach copies & pastes a new line in a sequence of planning days, for example, planningday=1, then 2, then 3...until the set number is reached.

    I added the code to assign a "Day 1" when planningday =1, and "Day 2" when planningday =2. I have two problems though, I can not get my formula to replicate in subsequent cells, i.e. each line that is copied & pasted in should be assigned a "Day #" and also as it is set up now, the day changes bc the planningday cycles 1 through set #., so when it starts, it reads correctly, Day 1, but by planning day 4, it reads Day 4, when the top line should say Day 1...then Day 2...then Day 3...etc.

    This is the code:
      'Creates Ranking
        Range("L1") = "%ofSS"
        
        Cells(1, 7).Select
        Selection.End(xlDown).Select
        numrecords = Selection.Row
        
        For ranking = 2 To numrecords
        Cells(ranking, 12) = "=IF(ISERROR((RC[-1]-RC[-2]-RC[-3])/RC[-4]),100,(RC[-1]-RC[-2]-RC[-3])/RC[-4])"
        Next ranking
        
        For planningday = 1 To Plandays
                
                dailybuild = 0
                            
                For dailybuild = 1 To 1000
            
                Columns("G:L").Select
                ActiveWorkbook.Worksheets("COL Schedule").Sort.SortFields.Clear
                ActiveWorkbook.Worksheets("COL Schedule").Sort.SortFields.Add Key:=Range("L1" _
                    ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
                With ActiveWorkbook.Worksheets("COL Schedule").Sort
                    .SetRange Range("G1:L91")
                    .Header = xlYes
                    .MatchCase = False
                    .Orientation = xlTopToBottom
                    .SortMethod = xlPinYin
                    .Apply
                End With
                
                Cells(2, 13) = Batchsize
                dailybuildtotal = dailybuildtotal + Batchsize
                Range(Cells(2, 7), Cells(2, 13)).Copy
                
                If firstbuild = 0 Then
                    Cells(2, 17).Select
                        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                        :=False, Transpose:=False
                    firstbuild = 1
                            
                
                    
                Else
                        Cells(1, 17).Select
                        Selection.End(xlDown).Select
                        Selectedrow = Selection.Row
                        Cells(Selectedrow + 1, 17).Select
                        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                        :=False, Transpose:=False
                End If
                
                If planningday = 1 Then
                Cells(2, 24) = "Day 1"
                 End If
                If planningday = 2 Then
                Cells(2, 24) = "Day 2"
                 End If
                If planningday = 3 Then
                Cells(2, 24) = "Day [/COLOR]3"
                 End If
                If planningday = 4 Then
                Cells(2, 24) = "Day 4"
                 End If
                If planningday = 5 Then
                Cells(2, 24) = "Day 5"
                End If
                
            
                
                Cells(2, 11) = Cells(2, 11) + Cells(2, 13)
                Cells(2, 13) = 0
                
                If dailybuildtotal >= Dailyrate Then Exit For
                
                Next dailybuild
                
                dailybuildtotal = 0
                
        
        Next planningday
        
       
        
    End Sub
    The italicized lines are what I added, I think my logic is too simple for what I need it to do.

    EDIT **I hope this works. I've had issues trying to get help with this.
    Here is an overview of what is going on, the table in COL Schedule is updated in the first set of code, then a ranking is created in the second set of code. It is ranked by columns K divided by H, which creates a percent of Safety Stock, then that is sorted within the same code least amnt to highest. So that the Item number with the biggest gap between the % and 100% is ranked at the top.
    Then, Based on what is ranked at the top, the program pulls a batch size (based on information put into the tab ColSched Start Here) and says we will build that batch size., it copies & pastes (values only) that line with the Batch size (also known as BuildQty) into Columns Q ~ W . Then the bacth size is added to the Oh Qty in Column K, then the entire list is resorted and the process is repeated, until the desired daily rate is reached (also in Tab ColSched Start Here). Then the entire process is repeated for the specified # of days, 1 to 5 or something. In the example given batch size 18, daily rate 54, days planned 4, so each time 3 lines would be pasted it would move to the next planned day.
    If you watch Column X, listed as Day, you will see the value fills in based on what day is being planned, 1~4 or given #. what I need is an assigned "day 1", "Day 2", etc, to fill in each time a line is pasted, and the value must match the lines planned day not the current planned day.

    I'm horrible at explaining things, I hope this isn't too big a mess.**
    Attached Files Attached Files
    Last edited by BREECHEEZ87; 02-27-2017 at 03:17 PM. Reason: Broke Rules.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Vlookup - how to make it move right to left
    By Deeintex in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-28-2015, 03:04 PM
  2. [SOLVED] Make button move when clicked
    By ed67 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-09-2015, 09:02 AM
  3. how to make cells move
    By moley165 in forum Excel General
    Replies: 2
    Last Post: 08-17-2012, 06:31 AM
  4. Replies: 4
    Last Post: 01-25-2012, 03:18 PM
  5. how to make the TAB key move to a new row?
    By djkatt in forum Excel General
    Replies: 2
    Last Post: 08-29-2007, 10:58 AM
  6. Move values to make a list
    By Optitron in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-05-2005, 04:05 PM
  7. [SOLVED] How to make command buttons move among worksheets?
    By Rick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-21-2005, 01:05 PM

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