Results 1 to 10 of 10

Thread: Excel query

  1. #1

    Default Excel query

    Been given a (very complicated!) Excel spreadsheet that's not working. Its been changed here, there and everywhere and normally when I write one I do it from scratch - trying to fix what someone else wrote is complicated. A lot of features written originally linked in with a piece of software we don't have so they've been commented out etc and its all a bit confusing.

    I'm trying to get my head around it, looking at the macro code and I'm puzzled by this definition:

    Dim dtime(11, 4) As Variant

    I thought variant was open-ended, I've never really used it. What does the (11, 4) mean? There are more examples throughout of variables being defined as variant with two numbers in brackets, not seen that before.

    In the context its used it appears to be a two-dimensional array of references from 0 - 11 across and 0-4 down.

  2. #2
    It's what you think it is. A declaration of a 12x5 array of variants, indexes starting with 0 in both dimensions.

  3. #3
    Thanks. I'm sure this is going to sound stupid but if I want a macro to delete an array, in this instance the range cd15:cd50 how do I do that? Having a mind fart right now.

  4. #4
    http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx

    edit: wait, did you want to delete the array, or the sheet range? Are you asking about deleting a matrix?

  5. #5

  6. #6
    Range("CD15:CD50").Select
    Selection.ClearContents

  7. #7
    OK, that's worked but its leaving the range visibly highlights when you return to the spreadsheet.

    Tried simply Range("CD15:CD50").ClearContents but its not working either as its causing an error due to it trying to change part of a merged cell.

  8. #8
    Fixed it.

    dim blank as range
    Set blank = Range("CD15:CI51")
    blank.ClearContents

  9. #9
    Sometimes I can't tell if I should get an MBA or just take an Excel course. I've heard they are very similar.

  10. #10
    De Oppresso Liber CitizenCain's Avatar
    Join Date
    Apr 2010
    Location
    Bottom of a bottle, on top of a woman
    Posts
    3,423
    Excel course won't teach you what the formulas mean, just how to use MS macros to calculate the result of... all those squigglies.

    But, don't take an Excel course. If you wanna go that route, take a broader programming course. That way you can write up Office Macros for silly banks and dinosaur businesses that use Excel for everything, and also have useful skills for businesses that actually use reasonable tools for the jobs they want done.
    "I predict future happiness for Americans if they can prevent the government from wasting the labors of the people under the pretense of taking care of them."

    "The tree of liberty must be refreshed from time to time with the blood of patriots and tyrants."

    -- Thomas Jefferson: American Founding Father, clairvoyant and seditious traitor.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •