Results 1 to 6 of 6

Selecting rows for copying via VB script

Threaded View

  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
    Sub exercise
    Range ("3:3, 5:5, 8:8").select
    End Sub
    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...
    Sub Exercise
    dim sheetloop as integer
    for sheetloop = 0 to 100
    sheetloop = sheetloop + 12
    Range ("sheetloop:sheetloop").select
    sheetloop = sheetloop - 1
    next sheetloop
    End Sub
    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.

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