+ Reply to Thread
Results 1 to 2 of 2

Filling Modules in a Trapezoid Shape Using Excel VBA

  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

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,706

    Re: Filling Modules in a Trapezoid Shape Using Excel VBA

    crossposted: https://www.mrexcel.com/board/thread...l-vba.1263821/

    Rule 7: Cross-posting Without Telling Us

    Your post does not comply with Rule 7 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this.

    I have added the crosspost reference for you today. Please comply with this and all our rules in the future

    However, if you continue to crosspost, you can expect to have your thread BLOCKED until you update it yourself.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

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. [SOLVED] 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