+ Reply to Thread
Results 1 to 3 of 3

Selecting range based on adjacent column

  1. #1
    Registered User
    Join Date
    06-28-2007
    Posts
    27

    Selecting range based on adjacent column

    I'm desperately in need of some VB help with a macro i created to pull in several reports...I would like to copy the data from one worksheet to another in the same workbook. However, the number of rows for every worksheet will be different everytime. I would like to have code in the macro to select the range automatically rather than putting a range (A2:E2500).

    Below is the code that gives me a runtime error 1004. Any help would be much appreciated...

    Sheets("Admin Expense Report 2007").Select
    Range("B2").Select
    x = Range("A65536").End(x1Up).Row
    ActiveSheet.Range(Cells(2, 1), Cells(x, 10)).Select
    Selection.Copy
    Sheets("Admin Expense Report 2006").Select
    Dim LastRow As Long
    With ActiveSheet
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    ActiveSheet.Paste
    End With
    Columns("J:J").EntireColumn.AutoFit
    ActiveWindow.LargeScroll ToRight:=-1

    j.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Remember to wrap your code with Code tags.

    You don't need to Select a Range to copy it. Try

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-28-2007
    Posts
    27
    Roy,
    Thanks a lot for your help. I realized a few hours after my posting that I had an error in the code. I had a 1 instead of that symbol that looks like a 1.

    Thanks again,

    Juan Andres

+ 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