+ Reply to Thread
Results 1 to 6 of 6

Selecting rows for copying via VB script

  1. #1
    Registered User
    Join Date
    10-13-2009
    Location
    Wigan
    MS-Off Ver
    Excel 2007
    Posts
    14

    Selecting rows for copying via VB script

    Hello everyone.

    I am trying a little program to see if I could select full rows for copying.

    the code i use is as follows
    Please Login or Register  to view this content.
    that works perfectly as it hightlight rows 3, 5, and 8 but I want to be able to select rows 12, 24, 36, 48, 60, etc....

    So I thought I could use a code something like...
    Please Login or Register  to view this content.
    Please forgive the VB grammar. I know it may be completely wrong as I am a newbie at VB, but I hope that you get the gist of what I want to do.

    The error I get is 'Run-time error '1004': method 'Range' of object'_Global' failed.
    I believe variables cannot be used in 'Range' functions. Or maybe?????

    Also, another option is that I could have an INPUT saying 'What increment do you want to choose rows??'
    If the user enters '10', then the rows 10, 20, 30, 40, etc are selected.
    Is this also possible??

    Thank you very much for looking.
    Last edited by cjboydell; 01-26-2010 at 12:43 PM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Selecting rows for copying via VB script

    Hi,

    One possibility:

    Please Login or Register  to view this content.
    Hope it helps,

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Selecting rows for copying via VB script

    perhaps this will get you started:

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Registered User
    Join Date
    10-13-2009
    Location
    Wigan
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Selecting rows for copying via VB script

    Thank you ...thats absolutely brilliant!!!
    Last thing.
    I noticed that you have only done 10 steps using
    Please Login or Register  to view this content.
    Could I use an input box to say how many rows to step rather than keep going back into the code to change the number of steps??

    Anyway Domski...you are a star!! Thankyou

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Selecting rows for copying via VB script

    Two options...

    This will repeat all the way down column A until the last entry:

    Please Login or Register  to view this content.
    And this will do it x number of times the user specifies:

    Please Login or Register  to view this content.
    Dom

  6. #6
    Registered User
    Join Date
    10-13-2009
    Location
    Wigan
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Selecting rows for copying via VB script

    Thank you very much Domski. That is exacty what I was looking for.

    All the best to you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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