Results 1 to 2 of 2

use input from user

Threaded View

  1. #1
    Registered User
    Join Date
    01-24-2010
    Location
    brussels
    MS-Off Ver
    Excel 2007
    Posts
    11

    use input from user

    Hi,
    Please read the forum rules and in particular the ruke about wrapping code lines inside CODE tags. I have done it for you on this occasion as this is your first post.

    Original post......

    Hello,

    I want to copy rows from one sheet to another sheet, but this number of rows is different every time. Also the first row to select is not always the same. I want to use an input box in which the user can enter a number. This number needs to be used to determine which rows have to be copied according to this formula:
    first row to copy = 2*Number + 8
    last row to copy = 4*Number + 9

    I created this macro but it doesn't work. What am I doing wrong?

    Sub inputbox()
    
    Sheets("Sheet1").Activate
    Dim Number As Integer
    Set Number = Application.inputbox( _
        prompt:="Enter number", Type:=1)
        Sheets("Sheet1").Select
        Rows("8+2*Number:9+2*Number").Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A1").Select
        ActiveSheet.Paste
    End Sub
    Thanks a lot.
    Last edited by Richard Buttrey; 01-28-2010 at 06:27 AM. Reason: Missing Code tags

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