+ Reply to Thread
Results 1 to 12 of 12

How to Range("A1:G & totrows")

  1. #1
    Registered User
    Join Date
    11-16-2020
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    10

    How to Range("A1:G & totrows")

    Hello, how is the syntax to make something like this work?

    Please Login or Register  to view this content.
    Thank you!
    Last edited by alejaninwow; 11-30-2020 at 04:54 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: How to Range("A1:G & totrows")

    Hi
    change to
    Please Login or Register  to view this content.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: How to Range("A1:G & totrows")

    You've just put the quotation marks in the wrong place:

    Please Login or Register  to view this content.
    Rory

  4. #4
    Registered User
    Join Date
    11-16-2020
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    10

    Re: How to Range("A1:G & totrows")

    Quote Originally Posted by mohadin View Post
    Hi
    change to
    Please Login or Register  to view this content.
    Thank you so much mohadin!

  5. #5
    Registered User
    Join Date
    11-16-2020
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    10

    Re: How to Range("A1:G & totrows")

    Quote Originally Posted by rorya View Post
    You've just put the quotation marks in the wrong place:

    Please Login or Register  to view this content.
    Yesss, noobs's fail hehe
    thanks!!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to Range("A1:G & totrows")

    Also note that, in the majority of cases, if not all, you can avoid Selecting ranges, or other objects. That will make your code shorter and more efficient and it will avoid interaction between the worksheet and VBA.

    It might be worth sharing all your code for advice.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  7. #7
    Registered User
    Join Date
    11-16-2020
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    10

    Re: How to Range("A1:G & totrows")

    Quote Originally Posted by TMS View Post
    Also note that, in the majority of cases, if not all, you can avoid Selecting ranges, or other objects. That will make your code shorter and more efficient and it will avoid interaction between the worksheet and VBA.

    It might be worth sharing all your code for advice.
    Hello TMS,

    Yes, I have noticed that is inefficient but I dont know how to program it. Also I am having an error "Select method of Range class failed" in the line Range("Z1:AE" & totrows).Select. Maybe it is because it takes a lot of time to load and the macro start running without being loaded the worksheet?

    So, my intention is loading a sheet from other workbook, filtering it and copying the rows and columns that I need in a new sheet. The code is:

    Please Login or Register  to view this content.
    Last edited by alejaninwow; 11-27-2020 at 08:20 AM.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to Range("A1:G & totrows")

    Untested, but try:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: How to Range("A1:G & totrows")

    I think the active sheet changes here:

    Please Login or Register  to view this content.
    so you'd need to split that into two With blocks.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to Range("A1:G & totrows")

    Picking up on rorya's comments, maybe this:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    11-16-2020
    Location
    Spain
    MS-Off Ver
    2016
    Posts
    10

    Re: How to Range("A1:G & totrows")

    I really appreciate your help, I tried it and it's working! Thank you!!

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to Range("A1:G & totrows")

    You're welcome.

+ 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. Replies: 11
    Last Post: 06-05-2020, 02:08 AM
  2. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  3. VBA - Excel 2013 - WorksheetFunction.CountBlank
    By dude6571 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2017, 05:33 PM
  4. [SOLVED] If Not ActiveSheet.Range("A1").Value Like "apple" Then MsgBox "Error"
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2014, 02:16 PM
  5. Replies: 5
    Last Post: 01-23-2014, 11:02 AM
  6. if Range("A1") = "Mike" Then Range("A1") = "michael" Then Exit Sub
    By a8015945 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-30-2013, 10:08 AM
  7. use variable in Workbooks("book1").Worksheets("sheet1").Range("a1"
    By Luc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2005, 04:05 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