+ Reply to Thread
Results 1 to 6 of 6

Offset.Resize in VBA Code not working

  1. #1
    Registered User
    Join Date
    12-19-2020
    Location
    Turkey
    MS-Off Ver
    2019
    Posts
    19

    Offset.Resize in VBA Code not working

    Hi Guys,

    I have created a VBA code with help of a friend. The code copies contents of 2 columns on a sheet to a new sheet. But when I try to extend the code to copy more columns it just does not work. To be more clear it does not copy all of the cells below. Especially when I try to set it to 2 letter columns it straight up does not copy anything, but that's a more minor issue. Please see the code.

    When I change the rngSrc "to.Range("F5", .Range("Q" & Rows.Count).End(xlUp))" for example the error occurs. I suspect that this is due to the offset function used below, but I don't really know.

    Thanks for the help in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,229

    Re: Offset.Resize in VBA Code not working

    Please see yellow banner above about attaching a sample file...
    Ensure file is exact same setup as actual and explain what you are actually trying to achieve...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Offset.Resize in VBA Code not working

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are new, I will provide the link for you this time: https://www.mrexcel.com/board/thread...rking.1156437/.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Offset.Resize in VBA Code not working

    Set rngSrc = .Range("F5", .Range("G" & .Rows.Count).End(xlUp).Row)
    Ben Van Johnson

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Offset.Resize in VBA Code not working

    protonLeah

    That will cause an error, .Range("G" & .Rows.Count).End(xlUp).Row will return a number, not a range.
    If posting code please use code tags, see here.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Offset.Resize in VBA Code not working

    I guess I shouldn't try to code in the forum edit box
    How about:
    Set rngSrc = .Range("F5", "G" & .Cells(.Rows.Count, "G").End(xlUp).Row)

+ 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. resize/offset property not working... Error 1004
    By instantjesus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-24-2014, 09:55 AM
  2. [SOLVED] VBA LastRow With Offset & Resize
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-21-2014, 09:55 AM
  3. vba offset and resize
    By juster26 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2012, 01:04 PM
  4. Can Resize and Offset be used on a range at the same time?
    By BeefNoodleSoup in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-28-2011, 06:56 AM
  5. code to find text, offset 1 column and paste to new workbook not working
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2011, 07:55 AM
  6. Offset and Resize
    By arvin in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-23-2010, 06:02 PM
  7. select range using offset or resize property
    By longhorn23 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-07-2010, 06:16 PM
  8. using .resize or an offset
    By cereldine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2006, 12:55 PM

Tags for this Thread

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