Posts by StefanG


    Range A1:A6 is merged into 1 range.

    Cells B1, B2, B3, B4, B5, and B6 are not merged. Same for columns C, D, E, and F.

    I can manually select row (header) 3 and insert an entire row. (Range A1:A6 becomes A1:A7.)

    I am unable to replicate this in VBA, with recorded steps or otherwise - it always enters 6 rows instead of 1 single row.

    Old age, lack of gray matter,... what gives?

    Thank you kindly for your guidance,


    Thank you very much for taking the time looking at my problem.

    Example 1, and Example 3 provide the correct results, also when manipulating the data the results are as expected! - Excellent. - That is, unless I add duplicate dates.

    Example 2, does not produce the desired result. expected count is 5, whereas it returns 10.

    I attempted a 'Sumproduct' approach and never got anywhere near where you are. - Unfortunately I am still not wise enough to figure what and how to tweak to make it also work for instances such as in Example 2.

    I added my test file with the different scenarios in case it will help; sorry for not including it originally already.


    Record Count Eval Test.xlsx


    I need a count of unique records (exclude duplicates) based on multiple criteria.

    Issue at hand is that one Line can have multiple records per day per shift - we need to know how many days a Line, per shift, worked between two dates, not how many records there are.

    • Data is located on Sheet 'Data'
    • Output is located on Sheet 'Output'

    Below some examples and basic layout references.

    Thank you for your guidance,


    • Sheet 'Data' - A = Date
    • Sheet 'Data' - B = Shift
    • Sheet 'Data' - C = Line
    • Sheet 'Data' - D = Value - Note: ignore record in count altogether if value = 0, or value = ""

    Following example should return count = 10

    • 10 unique records on 1 Shift (Shift 1) one record per Date (in 04/01/20 - 04/30/20), per Line (A), with Value <> 0, or <> ""


    Following example should return count = 5

    • 5 unique records on 1 Shift (Shift 1) one record per Date (in 04/01/20 - 04/30/20), per Line (A), with Value <> 0, or <> ""


    Following example should return count = 1

    • 1 unique record on 1 Shift (Shift 1) one record per Date (in 04/01/20 - 04/30/20), per Line (A), with Value <> 0, or <> ""


    • Sheet 'Output' - B1 = C_Date_Start (for example 04/01/20)
    • Sheet 'Output' - B2 = C_Date_End (for example 04/30/20
    • Sheet 'Output' - A4 - Line (for example A)
    • Sheet 'Output' - B3-D3 - Shift
    • Sheet 'Output' - B4 = C_Shift_1 - 1
    • Sheet 'Output' - C4 = C_Shift_2 - 2
    • Sheet 'Output' - D4 = C_Shift_3 - 3

    Date Start 04/01/20 . .
    Date End 04/30/20 . .
      Shift Shift Shift
    Line 1 2 3
    A . . .
    B . . .
    C . . .
    D . . .
    E . . .
    F . . .
    G . . .
    H . . .
    I . . .
    J . . .
    K . . .

    Hello Carim,

    Thank you for writing; point taken. :)

    A sample file to illustrate your approach ... is a must ... !!! :wink:

    I have mocked up a sample that I hope will help. - Not shown would be the step where, after the process renumbers the task #'s, the list would be sorted to put in proper order 1...5...10... etc.

    Hopefully the three samples will help you to help me. :)

    Thank you,



    We have a list of tasks:

    • Many already done and flagged as “Complete”
    • Many flagged as “Pending”
    • About 10 tasks at a time ranked from do first = 1, to do last = 10.

      • When 1 is moved to “Complete”, 2 becomes 1, 3 becomes 2, etc.
      • Then one from the “Pending” group may be moved to 10 right away.... or not.
      • Then we sort the list.
      • This is done manually.

    At times we need to switch the order where, for example:

    • 9 gets higher priority and may become 2. Then 2 goes to 3, 3 to 4 etc.
    • Another time we may bounce a “Pending” task to a priority level already set. So, if task “Pending” moves to 2, then old 2 goes to 3, 3 to 4,...10 goes to 11.
    • Some times we move an assigned task, such as task 2 back to “Pending”, then 3 moves to 2, 4 to 3, etc.

    We are looking to increase the ranked number of tasks from the current 10 to about 60. Doing any task number renumbering manually will turn your hair gray!

    I would think that vba might be able to handle this via perhaps workbook selection change on the “Task Status” column (A) to see

    • what change was made and then renumber tasks when needed (when a number was added, changed or removed),
    • assuring we have consecutive numbering starting at 1

      • (the max number is not set and only determined by however many tasks are currently numbered - today we have sometimes only 6 and other times 12, and “tomorrow” we may have 50 one time and the next 65),

    • without duplicating task numbers,
    • and by preserving the order of tasks.

    Though sadly, i haven't got a clue nor was i able to find any bits here or online that might get me on the right track.

    Assistance with this project would be much appreciated.

    Thank you,


    Thank you jolivanes.

    I remember having tried that before but could not remember the outcome, so repeated the task with one of the simpler formulas.

    The following takes the date entered in a cell in column B (R_Date), uses its Excel Date value and adds the row number as 4 digit code - whereas 02/02/18 in B10 becomes 431330010 in A10 (column A (R_RecordNo)) when it functions as desired.

    • I changed
      .... "=[COLOR=#0000FF]RC[1][/COLOR]&TEXT(ROW(),""0000"")"

    • To
      ".... =[COLOR=#0000FF]Range(""R_Date"")[/COLOR]&TEXT(ROW(),""0000"")"

    • The result changes from the desired 431330010 with the formula in A10 being =B10&TEXT(ROW(),"0000")
    • The result is now a #Name? error with the formula in A10 being =range("R_Date")&TEXT(ROW(),"0000")

    I suppose if nothing else it requires not only the column reference, but also a row reference; the formula, when placed via macro into the cell, does not know what to do with the 'Range' bit - and I need to have the formula placed in the cell, not just the resulting value in case that matters. - Variations of placing a 'R' (Row) reference for the RC (R1C1) reference style I attempted failed.

    Thank you,



    • I have several named ranges for columns, for example: 'R_ScoreDelivery' for column BG
    • Via macro I am adding several calculations that take place within a row, for example: .... IF(OR(RC[-14] ... where in this instance RC[-14] points to column 'R_ScoreDelivery'

    Is there a way to move away from the 'C[-14]' and incorporate the named range 'R_ScoreDelivery' instead so as to having a more flexible macro if columns were to be added/removed in-between at some point?

    Thank you for your advice,


    Re: Color Individual Lines Of Shape Group

    Andy, shg, Aaron,
    thank you very much for all your help. This is great. Now i have a couple different ways to go about. - My goal is not as complex as what shg has shown on the "world" sample. I am just trying to build a shape similar to Draw > AutoShapes > Basic Shapes > Bevel, that allows me to color the border parts, which cannot be done individually in the said shape set up. - Now i am off to applying what i learned here.Thank you again.

    Re: Color Individual Lines Of Shape Group

    this looks great!
    I am having difficulties understanding how this works. For practice i tried to create the same shape, same location, as in my sample, needless to say without luck. Excel's help is, well, not much help.
    May i ask if you are willing to help me further please? How would i use the approach you suggested, which i like alot, to create a shape using the data as shown in the sample in my original post, in the same location / coordinates of the sample?
    Thank you very much.

    since i have existing shapes, based on lines like in the sample. how do i translate that best?


    any idea how i could color fill a custom shape created by individual lines which are grouped together? The group behaves as one shape alright when, say, coloring the line, but is not "fillable". Below a simple sample. - The custom shape i am trying to color in is not a simple square or rectangle -not anything from the existing MS shapes that is.

    Thank you,


    Re: Remove Part Name/Caption From UserForm Controls

    Thank you.

    you are correct, I am seeking to replace the OptionButtons Caption, not the Name. My apology for misstating.

    May i please in inquire as to where to place/run the code - i'd like to have the Caption replaced/corrected permanantly, not only at the start of the UserForm.

    Thank you,

    Current OptionButton names are like ABC123, ABC 124, etc.

    How can i change all names, with code - as i am not seeing a find and replace option within UserForms, to all but the "ABC" part, the result of the OptionButton names shall therefor be 123, 124, etc. - delete "ABC" or, find "ABC" and replace with "".

    Re: Msoshapebevel - Change Color

    I have, briefly at this point, looked at your suggestion.

    At this point I find the following quite promising. - I created four shapes (trapezoids) manually, named them, and then grouped them together. Now I can color them any which way I want by calling the respective shapes name - see at the end. Looks and generally behaves as the beveled shape. I can manually change the size for the group by draging the handles, just as usual. - So far so good.

    Now I need to figure out how I can resize the group automatically. I can get its current size (I found the following snippet helpful):

    For Each shp In Sheets("sheet5").Shapes
       myleft = shp.Left
       mytop = shp.Top
       mywidth = shp.Width
       myheight = shp.height
    Next shp
    MsgBox mywidth & " " & myheight

    How can I resize using custom sizes?

    Selection.ShapeRange.ScaleWidth 1.75, msoFalse, msoScaleFromTopLeft '1.75 stands for resizing to 175% of its original size

    If the current size shows me 50 (width) and 100 (height) and I want it to respectfully be 190 and 75... it seems its just a math problem but I cant get my head around it.

    And, how can I dictate its Top and Left?

    Thank you,


    Re: Msoshapebevel - Change Color


    Thank you for your reply.

    I have been trying different approaches, indluding "msoShapeIsoscelesTriangle" and "msoShapeTrapezoid".

    I only need the four outside trapezoids as you identified correctly. I need to be able to color them individually - as in attached image. What shapes are in the backgroup does not matter as the square/rectangle center will be covered up, potentialy hiding part of the shapes used to achieve the border effect.

    I dont know how to line these individual shapes up so that the corner pieces line up. Any suggestion?

    Thank you,


    msoShapeBevel results in a shape with 5 sections. How can I color top and bottom in one color, left and right in another and the center in a third color/or blank?
    Thank you,

    Sub test()
    Worksheets(3).Shapes.AddShape msoShapeBevel, 50, 50, 100, 200
    End Sub

    Re: Splitting A Number Into Segments

    Hi Ian,
    I like your lookup option.



    Nice and short - sweet.
    I'd done this a bit longer once again, so i liked your solution.

    I suppose that triste will have to change the reference from A2 to A1 in your formula in F2 unless s/he had a typo.


    so I need that uumber in cell (a1) to be extracted acoording to that role and give me the final result


    Re: Splitting A Number Into Segments

    Hi triste,
    I'm sure there are better and shorter solutions.

    Say you have the Names of your loan officers in column A and their case numbers or so in column B - so in column A you could find the name(s) of loan officers multiple times, once for each case processed.

    Place this in C1
    =COUNTIF(A:A,"Name") - where Name will need to be replaced with the name of a Loan Officer. Copy the formula down and add all other respective Names.

    Place this in D1 (and copy down as needed as well).

    Not sure about your calculation part.
    If one has, say 20 cases, will the payout be 20x8? If that, I'd add another cell to the right and do
    =Sum(C1xD1) (copy down once again)