Results 1 to 5 of 5

Need to fill conditional cell values based on unknown number of rows

Threaded View

smokebreak Need to fill conditional cell... 12-15-2009, 11:19 AM
Domski Re: Need to fill conditional... 12-15-2009, 11:56 AM
smokebreak Re: Need to fill conditional... 12-15-2009, 12:08 PM
Domski Re: Need to fill conditional... 12-15-2009, 12:40 PM
smokebreak Re: Need to fill conditional... 12-15-2009, 02:16 PM
  1. #1
    Registered User
    Join Date
    12-15-2009
    Location
    Houston, TX, USA
    MS-Off Ver
    Excel 2007
    Posts
    86

    Need to fill conditional cell values based on unknown number of rows

    Hi,
    I just started using VBA and macros today, so please be kind!

    I have a set of data in column R, with an unknown number of rows that looks like this

    Days Late
    -28
    150
    3
    16
    41
    .
    .
    .

    and I have written a script to add an adjacent column "S". I want to fill column S with conditional values based on the value of column R, sorted into categories such as "On Time", "Less than One Month Late", etc. Here is what I have so far, it doesn't work:

    Sub Open_Order_Days_Late_Category()
    '
    ' Open_Order_Days_Late_Category Macro
    '
    
    '
        Columns("S:S").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Selection.ColumnWidth = 50
        
        Select Case Range("R:R").Value
            Case 1 To 6
                Range("S:S").Value = "Less than one week late"
            Case 7 To 14
                Range("S:S").Value = "One to two weeks late"
            Case 15 To 30
                Range("S:S").Value = "Two weeks to one month late"
            Case 31 To 60
                Range("S:S").Value = "One to two months late"
            Case 61 To 90
                Range("S:S").Value = "Two to three months late"
            Case 90 To 9999999
                Range("S:S").Value = "More than three months late"
            Case Else
                Range("S:S").Value = "On Time"
        End Select
        Range("S1").Select
        ActiveCell.FormulaR1C1 = "Days Late Category"
        With ActiveCell.Characters(Start:=1, Length:=18).Font
            .Name = "Calibri"
            .FontStyle = "Bold"
            .Size = 11
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontMinor
        End With
    
    End Sub
    Can someone please help me fix this code to make it work?
    Last edited by smokebreak; 12-15-2009 at 02:16 PM. Reason: Problem solved.

Thread Information

Users Browsing this Thread

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

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