Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. DougAJ4

    Sorting a multi-dimensional array in Excel VBA 2007

    I have an open source VBA sort function here: http://newtonexcelbach.wordpress.com/2009/03/23/a-sort-function/ The function can be used either from within VBA, or as a UDF to provide a dynamic sort. There is also a link to a Chip Pearson article on sorting by transfer to the spreadsheet and...
  2. DougAJ4

    Range to Array. Why doesn't this line work?

    Or to put the values into a variant array, rather than a range object: With Worksheets("Customers") rngBags = Range(.Range("B1"), .Range("B1").End(xlDown)).Value2 end with Doug Jenkins http://newtonexcelbach.wordpress.com/
  3. DougAJ4

    Help in declaring Variables

    Yes, stick to Longs with Excel VBA. Using Integers will just slow things down as they are converted to Longs anyway. Doug Jenkins http://newtonexcelbach.wordpress.com/
  4. DougAJ4

    VBA UDF array fn (ctl-shf-ent) - finding size of spec'd return range

    and hi electricpete :) Doug Jenkins http://newtonexcelbach.wordpress.com/
  5. DougAJ4

    VBA UDF array fn (ctl-shf-ent) - finding size of spec'd return range

    I didn't read what Chip had to say about it, but when you return an array as a UDF return value it doesn't have to be the same size as the selected range. If the selected range is smaller then the excess values just won't be displayed (they are still available to the =INDEX function), or if it...
  6. DougAJ4

    Refer to CurrentRegion in a UDF?

    If I understand you correctly, you can assign the array to the function return value, then enter the function as an array function (press ctrl-shift-enter). Doug Jenkins http://newtonexcelbach.wordpress.com/
  7. DougAJ4

    VBA Efficiency

    Groves22 - You seem to be doing a lot of work on the spreadsheet using VBA; e.g. .Range("D7:D10").Value = scrap.Sheets(1).Range("D" & j + 1 & ":D" & j + 4).Value etc I'm suggesting you could read the contents of your scap sheet(s) into an array, process that entirely within VBA, then write the...
  8. DougAJ4

    VBA Efficiency

    Rather than working with range objects I'd recommend reading in the data as a variant array, working on that, then writing it back to the spreadsheet: dim BigBlockofData as variant, BigBlockofData2 as variant BigBlockofData = Range("name or address").value2 ' Do some stuff on BigBlockofData...
  9. DougAJ4

    Multiplication with Double Data types

    A few more comments: If you enter the number as a decimal (100.0) the VB Editor will change it to 100# for you. If you step through the routine and click on help when it hits the problem the help gives the reason for the problem, as given earlier in the thread. (I confess to being amazed that...
  10. DougAJ4

    Adding time

    That checks if aTime is no more than 2 hours less than lastaTime. You need: If (CDate(aTime) - TimeValue("02:00:00")) >= CDate(lastaTime)) then ... Doug Jenkins http://newtonexcelbach.wordpress.com/
  11. DougAJ4

    Declaring variables

    An array of doubles does not have any format information. You can assign the array to a range, and then apply the formatting, or use a range rather than an array in the first place. Doug Jenkins http://newtonexcelbach.wordpress.com/
  12. DougAJ4

    Array question

    Watersprite - the first thing is if you are using a named range you don't need to qualify it with the Worksheets("sheet5"). Secondly if you have a named range for the output you won't need to hard code the worksheet and location. But the advantage of using an array is that you can do all the...
  13. DougAJ4

    Array question

    What is the objection to using an array? It's much faster than working on a range, for one thing. Doug Jenkins http://newtonexcelbach.wordpress.com/
  14. DougAJ4

    Remove "=" from cell with VBA in Excel

    The line Cell.value = cell.formula should do what you want: Sub ConvertEq() Dim textrange As Range, cell As Range Set textrange = Range("myrange") For Each cell In textrange.Cells cell.Value = cell.Formula Next cell End Sub Doug Jenkins http://newtonexcelbach.wordpress.com/
  15. DougAJ4

    Mispositioned Shapes

    I tried the code posted by Skip in XL2007, and it seems to work, with ribbon visible or hidden, using a simple rectangular shape. I know that the way in which arcs are specified changed in 2007. Could that have anything to do with it? Doug Jenkins http://newtonexcelbach.wordpress.com/
  16. DougAJ4

    Can't Activate VBA with this code

    You can call a function from another VBA routine, or you can enter it on the spreadsheet in the same way as the built in Excel functions, but if you want to run it from the Macro list, or attach it to a button, you will have to either make it a Sub or write a short Sub that calls the function...
  17. DougAJ4

    Can't Activate VBA with this code

    Nodes isn't defined in the code as posted, but you should have got a message saying that when you tried to run it. What messages do you get? Doug Jenkins http://newtonexcelbach.wordpress.com/
  18. DougAJ4

    Floating point accuracy in VBA

    How much difference are you getting? There shouldn't be any difference up to the 14th significant figure. Was "Application.WorksheetFunction.Atan2(HypotA1A2, A3) a typo? It should be Atan2(adjacent, opposite) If you are using multiple copies of this function you will find a significant...
  19. DougAJ4

    VBA book for undergrad engineers

    I also have used and enjoyed John Walkenbach's Excel Power Programming. For a printed reference I can recommend Excel 2007 VBA - Programmer's Reference by Green, Bullen, Bovey and Alexander. It's definitely not a "get you started" text, but it's the most complete printed documentation that I...
  20. DougAJ4

    Extract complex equations from a string

    The Excel "Eval" function will do what you want, except it won't recognise user defined functions. You can find a spreadsheet with a UDF using this technique to evaluate integrals here: http://newtonexcelbach.wordpress.com/2008/07/05/evaluate-function-update/ If you follow the links from that...

Part and Inventory Search

Back
Top