Results 1 to 2 of 2

Filling Modules in a Trapezoid Shape Using Excel VBA

Threaded View

  1. #1
    Registered User
    Join Date
    06-03-2024
    Location
    Petersburg
    MS-Off Ver
    Excel 2021
    Posts
    3

    Exclamation Filling Modules in a Trapezoid Shape Using Excel VBA

    Hello everyone,

    I am still quite inexperienced in Excel VBA and have encountered a problem. The background:

    I would like to fill various shapes with small rectangles (‘modules’). The modules should always be the same size and their size is predefined. A minimum distance between the modules and to the edge of the respective shape is also specified. Taking these conditions into account, as many modules as possible should be generated symmetrically in the shape. The size of the mould should be variable so that the maximum number of modules can always be generated.

    This is not a problem with a rectangular shape (see ‘Sheet1’ and sub ‘GenerateModulesSquare’.

    Next, I tried my hand at a trapezoid. I first determined the 4 corner points of the trapezoid to determine the edges. I then used a loop to query whether there was room for another module + two safety distances to the edge (see subs ‘TrapezoidTooManyModules’ and ‘TrapezoidNotEnoughModules’).

    Especially with ‘TrapezoidNotEnoughModules’ I don't understand why gaps are left where there would actually be enough space for further modules.
    ‘TrapezoidTooManyModules’ looks better at first glance, but exceeds the edges of the trapezoid.
    Depending on whether you enlarge or reduce the size of the trapezoid, the malfunction becomes clearer. Neither of the two approaches works.

    I suspect that I am not calculating the left and right edges accurately and therefore the If queries are correct, but have the wrong basis.

    I would be very grateful for any advice!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro 4 sheet Mysterious appearing Worksheets & Modules. Codes transferred to New Modules
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-24-2016, 07:07 AM
  2. Replies: 6
    Last Post: 06-20-2016, 10:02 PM
  3. Excel 97 modules appear as tabs
    By Kate in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2005, 04:35 PM
  4. [SOLVED] Public, Private, Event modules, Forms modules,,,
    By Jim May in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-31-2005, 12:05 AM
  5. Editing text in text box grouped within a trapezoid
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-16-2005, 05:05 AM
  6. Basic question - modules and class modules - what's the difference?
    By Mark Stephens in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-08-2005, 07:08 AM
  7. Help creating a "trapezoid" shaped graph
    By danjr in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-29-2005, 10:11 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1