• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Search results

  1. Colin Legg

    VBA stops randomly

    If nothing else, it's always nice to be able to give your enemy a name. :)
  2. Colin Legg

    VBA stops randomly

    Sounds like phantom breakpoints to me?
  3. Colin Legg

    Excel - Error - .Refresh BackgroundQuery:=False

    Me too... 1-1 at half time... a nervous second half ahead! :)
  4. Colin Legg

    Excel - Error - .Refresh BackgroundQuery:=False

    In addition to fixing the connection string by adding the braces around the driver, one other problem might be the way you are reading the range into a string. For example, when you read in the cells which contain these lines: WHERE [Agent_Queue_Day].[DimDateKey] >= @Tel_StartDate AND...
  5. Colin Legg

    Excel - Error - .Refresh BackgroundQuery:=False

    I just noticed your connection string is wrong too. I don't see fname declared anywhere so I don't know what it is, but the SQL Server driver needs to be surrounded with braces: "ODBC;DRIVER={SQL Server};SERVER=CNWSQLH004P01" etc.....
  6. Colin Legg

    Excel - Error - .Refresh BackgroundQuery:=False

    A syntax error is a compile time error rather than a runtime error. It means that something you've written doesn't obey the rules the VBA compiler expects. I don't know if the space between the first two lines of this code just appeared when you copied the code into your post: With...
  7. Colin Legg

    Excel - Error - .Refresh BackgroundQuery:=False

    Hi, what is the error number and what is error message? Does the SQL run without error if you run it directly in management studio?
  8. Colin Legg

    Return value if no match found in Vlookup

    If you want to do this using Match and VLookUp then, with wom declared as a Variant type, you could do this... wom = Application.Match(vl6.Value, Sheet1.Range("A2:A" & Sheet1.UsedRange.Rows.Count), 0) If IsError(wom) Then Sheet11.Range("I" & vl6.Row).Value = "Not Assigned"...
  9. Colin Legg

    Somendra 2K Mishra

    Congratulations to both of you for your respective milestones! :)
  10. Colin Legg

    Sir Narayan ! 8000 +

    Congratulations on reaching another milestone! :)
  11. Colin Legg

    What is Array Formula

    Here's another one which I wrote many years ago.... http://www.xtremevbtalk.com/showthread.php?t=296012
  12. Colin Legg

    select range in columns

    Hi, There are various syntaxes/properties you could use; here's one of them: Range(Cells(4, nStart), Cells(4, nEnd)).Group
  13. Colin Legg

    select range in columns

    Hi Wim, If you want to use a Long variable to loop through the columns then you need to use column numbers rather than column letters: For nColumn = 1 To 703 If Cells(4, nColumn).Value = i Then If you want to use a Range object to loop through the columns then you can use a...
  14. Colin Legg

    SUMIF values based on each year, 2011, 2012, etc.

    Another formula option: You could define the start and end dates (inclusive) in two cells, say E1 and F1 and then use either of these: =SUMIFS(B1:B4,A1:A4,">="&E1,A1:A4,"<="&F1) or =SUMIF(A1:A4,">="&E1,B1:B4)-SUMIF(A1:A4,">"&F1,B1:B4) But I think you were on the right track with a...
  15. Colin Legg

    ElseIf Weekday Exit Sub vba

    Hi, The way the conditions in your ElseIf statement resolve themselves isn't what you want but, more importantly, the intention of your "And" condition can't ever be true because the weekday of date1 cannot be both a Saturday and a Sunday. I'm not sure about the validity of doing the cell...
  16. Colin Legg

    One Macro Code which can run different macro codes

    That's fine too - it's the same thing as I posted. The Call keyword in VBA is optional so in my example I just wrote the macro names without the Call keyword.
  17. Colin Legg

    One Macro Code which can run different macro codes

    Hi, Yes. Instead of having a set-up like this (which is what you described): Private Sub CommandButton1_Click() Do1 End Sub Private Sub CommandButton2_Click() Do2 End Sub Private Sub CommandButton3_Click() Do3 End Sub Private Sub CommandButton4_Click() Do4 End Sub Private...
  18. Colin Legg

    Delete range of rows based on cell values??

    There are better ways to do this but let's use your existing code as a basis. Sub DelRow() Dim LR As Long, i As Long LR = Range("C" & Rows.Count).End(xlUp).Row For i = LR To 11 Step -1 If Range("C" & i).Value = 0 Then Rows(i).Delete Next i End Sub You want a static range -...
  19. Colin Legg

    Weird things happening to Excel lately; now SUMPRODUCT isn't working properly

    Your formula in AC5 is =SUMPRODUCT(($J$6:$J$100=AB5)*($N$6:$N$47=AC4)) I'm not quite sure what that formula is meant to be calculating. Was it meant to be =SUMPRODUCT(($J$6:$J$100=$AB10)*($I$6:$I$100=AC$4)) If yes, then you could use COUNTIFS() which would be faster or you could even consider...
  20. Colin Legg

    Congratulations Luke on reaching 6,000 posts

    Wow, congratulations and keep up the good work! :)
  21. Colin Legg

    Input Box in VBA shouldn't display the text

    The built-in VBA Input Box does not natively support masking. You could write some very complicated code to achieve this with the input box, but a much better and simpler option would be to create a userform which looks just like the input box. The text entry area of the userform would be an...
  22. Colin Legg

    SUMPRODUCT / INSTR

    Please see attached.
  23. Colin Legg

    SUMPRODUCT / INSTR

    Your Type and Wbs columns (columns B and C) are switched around in the file, so the first formula (check "a", type "AC", wbs position 17 "3" or "6") would be like =SUMPRODUCT(--(A2:A22="a"),--ISNUMBER(MATCH(MID(C2:C22,17,1),{3,6}&"",0)),--(B2:B22="AC"),D2:D22) or...
  24. Colin Legg

    SUMPRODUCT / INSTR

    =SUMPRODUCT(--(A2:A5="a"),--ISNUMBER(MATCH(MID(B2:B5,17,1),{3,4}&"",0)),--(C2:C5="XX"),D2:D5) or, SUMIFS which is faster... =SUM(SUMIFS(D2:D5,A2:A5,"a",B2:B5,REPT("?",16)&{3,4}&"??",C2:C5,"XX")) or, DSUM() per Deb's post #16 which is even faster... just change the TRUE in F3 to a
  25. Colin Legg

    Using #temptable in OLE DB connection

    Hi, Yes they are allowed but make sure you use a SET NOCOUNT ON directive otherwise you'll have problems with trying to retreive data (due to the INSERT) into a recordset from your SELECT * FROM #temptable query.
Back
Top