Results 1 to 10 of 10

Thread: VBA Range.Insert Method: Code line makes a space to put new range in

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,456
    Rep Power
    10
    Using the VBA Range.Insert Code line when something is in the clipboard



    If anything other than a spreadsheet range is in the clipboard range then the behaviour of the VBA Range.Insert Code line is as discussed previously.
    What happens when a range is copied to the clipboard followed by a Range.Insert Code line is not simple to explain.
    I have not seen any clear official documentation on this. I expect it "works" as a method to Insert range data more by chance than by design.
    I can see a set of rules. I can summarise them in 2 Pints

    _Pint 1) The attempted new range dimensions.
    Unlike in the case for an empty clipboard, it does not follow that the actual range inserted will have the dimensions of that given in by the Range in Range.Insert. This probably goes unnoticed as often this "Method", that is to say this "combination of a Range.Copy followed by Range.Insert" is used to insert whole rows

    Consider a " "combination of a Range.Copy followed by Range.Insert" action."
    As in the case of nothing in the clipboard, a new Range is given, that being the Range in the Range.Insert Command. At the outset of the Insert command, it would appear that the range to be made free by the Insert command is not necessarily the Range. It appears to me that the Range will be adjusted , according to the Rules below. ( The command may or may not then be successful, that is to say it may or may not error ).

    For the purposes of clarity.
    Range is that copied to the clipboard
    and
    Range is the given range in Range.Insert
    and
    Range is the attempted range used finally in Range.Insert , .. in other words, if the action is successful then the actual action done is Range.Insert
    As will be discussed, Range will start at top left of Range but the actual range area used , Range, will be a contiguous rectangular range of cells comprising Full multiples of Range

    Rules:
    _ Pint 1a) Range >= Range
    _ P1a) The Range given , ( in the Range.Insert code line ) is equal to or larger than the Copy Range
    It appears that the attempted Range is either the copied Range or an exact multiple thereof.
    ___ P1a)(i) If it is possible to include an exact number of the copied Range dimensions within the Range specified as the new range to be inserted, then that will become the attempted effective Range in Range.Insert. In this case the Range in the Range.Insert command is an integer number of the copied Range held in the clipboard. It will be attempted to insert this Range. Top left of the given insert Range remains Top left of the inserted new Range
    ___ P1a)(ii) If it is not possible to include an exact number of the copied Range directions within the Range specified as the new range to be inserted, then the range attempted to be inserted will be the copied Range held in the clipboard. . Effectively the Range "shrinks" from that given in darkRange down on size to the copied Range.
    Range becomes Range
    Top left of the given insert Range remains Top left of the inserted new Range

    _Pint 1b) Range is < Range in 1 or more directions
    _P1b) The specified Range ( in Range.Insert ) is smaller than the Copy Range in either the horizontal direction or the vertical direction ( or both ).
    ___P1b)(i) If it is possible to include an exact number of the Copy Range width or an exact number the Copy Range height in the Range specified as the new range to be inserted, then that will become the attempted effective Range in Range.Insert. In this case the Range in the Range.Insert command is increase in the other direction to include the integer number of the Copy Range which do fit in one direction.
    Top left of the given insert Range remains Top left of the inserted new Range
    ___P1b)(ii) If it is not possible to include an exact number of the copied Range width or an exact number of the copied Range height within the Range specified as the new range to be inserted, then the Range attempted to be inserted will be the Copy Range held in the clipboard. Effectively the Range adjusts


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    http://www.eileenslounge.com/viewtopic.php?p=324457#p324457
    http://www.eileenslounge.com/viewtopic.php?p=324064#p324064
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    https://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgyZCnNfnZRfgwzDlQF4AaABAg
    https://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgyZCnNfnZRfgwzDlQF4AaABAg. ADd4m2zp_xDADd6Nnotj1C
    s://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgySdtXqcaA27wQLd1t4AaABAg
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?f=30&t=41784
    http://www.eileenslounge.com/viewtopic.php?p=323966#p323966
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    http://www.eileenslounge.com/viewtopic.php?p=323894#p323894
    http://www.eileenslounge.com/viewtopic.php?p=323843#p323843
    http://www.eileenslounge.com/viewtopic.php?p=323547#p323547
    http://www.eileenslounge.com/viewtopic.php?p=323516#p323516
    http://www.eileenslounge.com/viewtopic.php?p=323517#p323517
    http://www.eileenslounge.com/viewtopic.php?p=323449#p323449
    http://www.eileenslounge.com/viewtopic.php?p=323226#p323226
    http://www.eileenslounge.com/viewtopic.php?f=25&t=41702&p=323150#p323150
    http://www.eileenslounge.com/viewtopic.php?p=323085#p323085
    http://www.eileenslounge.com/viewtopic.php?p=322955#p322955
    http://www.eileenslounge.com/viewtopic.php?f=30&t=41659
    http://www.eileenslounge.com/viewtopic.php?p=322462#p322462
    http://www.eileenslounge.com/viewtopic.php?p=322356#p322356
    http://www.eileenslounge.com/viewtopic.php?p=321984#p321984
    https://eileenslounge.com/viewtopic.php?f=30&t=41610
    https://eileenslounge.com/viewtopic.php?p=322176#p322176
    https://eileenslounge.com/viewtopic.php?p=322238#p322238
    https://eileenslounge.com/viewtopic.php?p=322270#p322270
    https://eileenslounge.com/viewtopic.php?p=322300#p322300
    http://www.eileenslounge.com/viewtopic.php?p=322150#p322150
    http://www.eileenslounge.com/viewtopic.php?p=322111#p322111
    http://www.eileenslounge.com/viewtopic.php?p=322086#p322086
    https://stackoverflow.com/questions/33868233/shell-namespace-not-accepting-string-variable-but-accepting-string-itself/77888851#77888851
    http://www.eileenslounge.com/viewtopic.php?p=322084#p322084
    http://www.eileenslounge.com/viewtopic.php?p=321822#p321822
    http://www.eileenslounge.com/viewtopic.php?p=322424#p322424
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 01-23-2025 at 05:03 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Replies: 1
    Last Post: 06-26-2014, 12:50 PM
  2. Replies: 2
    Last Post: 02-27-2014, 05:01 PM
  3. Adapt VBA Code With Adjusment Range
    By muhammad susanto in forum Excel Help
    Replies: 2
    Last Post: 09-14-2013, 11:50 AM
  4. VBA Looping Input Range and Output Range
    By Whitley in forum Excel Help
    Replies: 7
    Last Post: 04-25-2013, 09:02 PM
  5. Replies: 7
    Last Post: 04-21-2013, 07:50 PM

Posting Permissions

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