Posts by ir121973

    Re: VBA Remove Characters


    Hi snb, thank you for taking the time to reply to my post, and for the solution.


    I have to admit the code I'm using was derived from items I've picked up off the web, and from help I've received through this project I'm working on, so it is very possible that this an incorrect way of writing this particular function.


    Many thanks and kind regards

    Re: VBA Remove Characters


    Hi jindon, thank you for taking the time to reply to my post and for the guidance.


    I've made the changes as you suggested, but sadly, this doesn't have the desired result.


    This part of the code works fine:



    Code
    With ws.Range("D5", ws.Range("D" & Rows.Count).End(xlUp))
                        .Value = Evaluate("if(row(" & .Address & "),replace(" & .Address & ",1,10,""""))")
     End With


    But the the column of data is removed completely from the other sheets in the array, which is controlled by this line of code:


    Code
    With ws.Range("C5", ws.Range("C" & Rows.Count).End(xlUp))
                        .Value = Evaluate("if(row(" & .Address & "),replace(" & .Address & ",1,10,""""))")
    End With


    So I'm not sure where I'm going wrong.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I've put together the following code which performs a number of actions within given columns in a sheet array.



    Unfortunately though I'm having a problem with the following sections of code which removes the first 10 characters from a text string:


    Code
    With ws.Range("D5", Range("D" & Rows.Count).End(xlUp))
                        .Value = Evaluate("if(row(" & .Address & "),replace(" & .Address & ",1,10,""""))")
    End With


    and


    Code
    With ws.Range("C5", Range("C" & Rows.Count).End(xlUp))
                        .Value = Evaluate("if(row(" & .Address & "),replace(" & .Address & ",1,10,""""))")
     End With


    When I run this, I receive Run time error '1004' Method Range of Object_worksheet failed' with debug highlighting this line as the cause

    Code
    With ws.Range("D5", Range("D" & Rows.Count).End(xlUp)

    ) and I've no idea why despite spending several hours on this with different permutations of code.


    In addition, I would like to add an 'IF' statement which states that the first character must be / before it removes the 10 characters.


    I just wondered whether someone may be able to look at this and let me know where I'm going wrong.


    Many thanks and the kindest regards

    Hi, I wonder whether someone may be able to help me please.


    I'm using the code below to perform a number of actions to a series of columns within a given array.



    You'll see that in this line

    Code
    ws.Range("G5:G" & LastRow).FormulaR1C1 = "=IF(RC[-2]<0.000,"""",RC[-2]-RC[-1])"

    I apply a formula and it's this that I'm having a little trouble with.


    The formula works find but I'm trying to add conditional format, whereby if the value in column G is => 0.00 I'd like the font to be green, if it <0.00 then I'd like the font to be red.


    I've done a fair bit of research, but I've been unable to find a sutiable solution which I can work at adapting.


    I just wondered whether someone may be able to look at this please and offer some guidance on how I may go about achieving this.


    Many thanks and kind regards

    Re: VBA Change Date Cell Value


    Hi All, thank you for taking the time to view my post.


    I've managed to solve this by using the following:


    Code
    With Range("I21")
    .NumberFormat = "@"
    .Value = Format(Date, "mmm yy")
    
    
    End With


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I've put together a script which consolidates sheets from multiple workbooks into a 'Summary' sheet.


    One of the columns contains dates which, when extracted, are in the format of "mmm yy", but the actual cell value is for example, "01/11/13 01:00:00".


    Could someone perhaps tell me please is there a way using VB, where I can replace the cell value from, and using the above example, "01/11/13 01:00:00" to "01/11/13". The reason I need to do this is so the cell value can be compared to another cell further along in my script.


    Many thanks and kind regards

    Re: VBA Multiply Figure By


    Hi Windy, thank you very much for taking the time to reply to my post and for the solution. It works great!


    Thank you for also for your time and trouble.


    Kind Regards

    Hi, I wonder whether someone may be able to help me please.


    I have the following sheet layout.


    [TABLE="width: 1500"]

    [tr]


    [td][/td]


    [td]

    COLUMN B

    [/td]


    [td]

    COLUMN C

    [/td]


    [td]

    COLUMN D

    [/td]


    [td]

    COLUMN E

    [/td]


    [td]

    COLUMN F

    [/td]


    [td]

    COLUMN G

    [/td]


    [td]

    COLUMN H

    [/td]


    [td]

    COLUMN I

    [/td]


    [td]

    COLUMN J

    [/td]


    [td]

    COLUMN K

    [/td]


    [td]

    COLUMN L

    [/td]


    [td]

    COLUMN M

    [/td]


    [td]

    COLUMN N

    [/td]


    [td]

    COLUMN O

    [/td]


    [td]

    COLUMN P

    [/td]


    [td]

    COLUMN Q

    [/td]


    [/tr]


    [tr]


    [td]

    ROW 3

    [/td]


    [td][/td]


    [td]

    22

    [/td]


    [td]

    23

    [/td]


    [td]

    20

    [/td]


    [td]

    23

    [/td]


    [td]

    22

    [/td]


    [td]

    21

    [/td]


    [td]

    23

    [/td]


    [td]

    21

    [/td]


    [td]

    22

    [/td]


    [td]

    23

    [/td]


    [td]

    20

    [/td]


    [td]

    21

    [/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    ROW 4

    [/td]


    [td]

    Description

    [/td]


    [td]

    Apr-13

    [/td]


    [td]

    May-13

    [/td]


    [td]

    Jun-13

    [/td]


    [td]

    Jul-13

    [/td]


    [td]

    Aug-13

    [/td]


    [td]

    Sep-13

    [/td]


    [td]

    Oct-13

    [/td]


    [td]

    Nov-13

    [/td]


    [td]

    Dec-13

    [/td]


    [td]

    Jan-14

    [/td]


    [td]

    Feb-14

    [/td]


    [td]

    Mar-14

    [/td]


    [td]

    Actual Hours Total

    [/td]


    [td]

    Mandays Total

    [/td]


    [td]

    FTE Total

    [/td]


    [/tr]


    [tr]


    [td]

    ROW 5

    [/td]


    [td]

    Project 1

    [/td]


    [td]

    1155.14

    [/td]


    [td]

    1463.71

    [/td]


    [td]

    1615.53

    [/td]


    [td]

    1333.76

    [/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td]

    232.01

    [/td]


    [td]

    32.05

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [/TABLE]



    What I'm trying to do, is add a formula via VBA in the "FTE" column (Column Q), which is as follows:

    • Search row 5 in columns C:N and find the month which matches the current date.
    • When a match is found, take the corresponding value from row 4 and multiply this value by the value in column P.
    • So using the above as an example, the formula in column Q on row 5, would be 22 multiplied by 32.05 giving a total of 705.10.


    Hi, I wonder whether someone may be able to help me please.


    I have the following sheet layout.


    [TABLE="width: 1500"]

    [tr]


    [td][/td]


    [td]

    COLUMN B

    [/td]


    [td]

    COLUMN C

    [/td]


    [td]

    COLUMN D

    [/td]


    [td]

    COLUMN E

    [/td]


    [td]

    COLUMN F

    [/td]


    [td]

    COLUMN G

    [/td]


    [td]

    COLUMN H

    [/td]


    [td]

    COLUMN I

    [/td]


    [td]

    COLUMN J

    [/td]


    [td]

    COLUMN K

    [/td]


    [td]

    COLUMN L

    [/td]


    [td]

    COLUMN M

    [/td]


    [td]

    COLUMN N

    [/td]


    [td]

    COLUMN O

    [/td]


    [td]

    COLUMN P

    [/td]


    [td]

    COLUMN Q

    [/td]


    [/tr]


    [tr]


    [td]

    ROW 3

    [/td]


    [td][/td]


    [td]

    22

    [/td]


    [td]

    23

    [/td]


    [td]

    20

    [/td]


    [td]

    23

    [/td]


    [td]

    22

    [/td]


    [td]

    21

    [/td]


    [td]

    23

    [/td]


    [td]

    21

    [/td]


    [td]

    22

    [/td]


    [td]

    23

    [/td]


    [td]

    20

    [/td]


    [td]

    21

    [/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td]

    ROW 4

    [/td]


    [td]

    Description

    [/td]


    [td]

    Apr-13

    [/td]


    [td]

    May-13

    [/td]


    [td]

    Jun-13

    [/td]


    [td]

    Jul-13

    [/td]


    [td]

    Aug-13

    [/td]


    [td]

    Sep-13

    [/td]


    [td]

    Oct-13

    [/td]


    [td]

    Nov-13

    [/td]


    [td]

    Dec-13

    [/td]


    [td]

    Jan-14

    [/td]


    [td]

    Feb-14

    [/td]


    [td]

    Mar-14

    [/td]


    [td]

    Actual Hours Total

    [/td]


    [td]

    Mandays Total

    [/td]


    [td]

    FTE Total

    [/td]


    [/tr]


    [tr]


    [td]

    ROW 5

    [/td]


    [td]

    Project 1

    [/td]


    [td]

    1155.14

    [/td]


    [td]

    1463.71

    [/td]


    [td]

    1615.53

    [/td]


    [td]

    1333.76

    [/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td]

    232.01

    [/td]


    [td]

    32.05

    [/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [/TABLE]



    What I'm trying to do, is add a formula via VBA in the "FTE" column (Column Q), which is as follows:

    • Search row 5 in columns C:N and find the month which matches the current date.
    • When a match is found, take the corresponding value from row 4 and multiply this value by the value in column P.
    • So using the above as an example, the formula in column Q on row 5, would be 22 (Because we are in August) multiplied by 32.05 (Cell P5) giving a total of 705.10.


    I know how to set up my sheet and range array using the code I've put together below, but it's the formula I'm having difficulty with.



    I just wondered whether someone could possibly look at this please and offer some guidance on how I may go about achieving this.


    Many thanks and kind regards

    Hi, I wonder whether someone could possibly help me please.


    I'm trying to put together a script which will highlight the highest and second highest value for each column in a given range for multiple sheets.


    I've started the script off below, which I think correctly creates the array of sheets and the starting row of each column.


    Now I did try to get some help here: http://www.excelforum.com/exce…ighlight-max-numbers.html but as you will see I seem to have hit a bit of brick wall.


    I just wondered whether someone could possibly look at this please, and offer some guidance on how I may go about achieiving this.


    Thank you and kind regards

    Re: VBA Create Unique Distinct Values List


    Hi snb. Thank you very much for your suggestion. Although I'd like to continue with jindon solution in this instance, but thank you for helping me to think a little less blinkered.


    I also like your website. I'll be looking at this over the next few days.


    Many thanks and kind regards

    Re: VBA Create Unique Distinct Values List


    Hi jindon, I can only apologise for my stupidity and illness, a long story.


    I can completely understand your frustration.


    Please find attached the file you've asked for. I have added two extra sheets called "Direct Activities Output" and "Indirect Activities" highlighting the desired outcome.


    Once again, my sincere apologies for really messing you around and thanks for all your time, trouble and patience.


    Kind Regards

    Re: VBA Create Unique Distinct Values List


    Hi jindon, that's great, but I'm afraid I've made a terrible, terrible mistake, I am so sorry!


    In the case of "DIR" and "IND", would it be at all possible please to copy the value from column D of the 'Source' sheet rather than column E, pasting into column B of the "Direct Activities" and "Indirect Activities" 'Destination' sheets.


    I feel a real idiot, for not spotting this before, I'm so very sorry. I promise you that this is the last change!


    Many thanks and kind regards.