+ Reply to Thread
Results 1 to 5 of 5

Macro not working

  1. #1
    Registered User
    Join Date
    07-17-2007
    Posts
    13

    Macro not working

    Hi,
    I posted a thread before asking about how to take data from several sheets and list it all (consecutively) in one column in a separate sheet (summary). The problem was that the data (in column I) had differing number of rows on each sheet, and i wanted it all listed in one column in order of sheet number. RYLO helped out by writing some code to do this....


    Sub aaa()
    Sheets("Summary").Range("A:A").ClearContents
    Sheets("Summary").Range("A1").Value = "distance"

    For i = 1 To Sheets.Count
    If Sheets(i).Name <> "Summary" Then
    With Sheets(i)
    .Range("A2:A" & .Cells(Rows.Count, 1).End(xlUp).Row).Copy Destination:=Sheets("Summary").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
    End With
    End If
    Next i

    End Sub


    However, it didnt quite work, maybe becuase my data were in column I instead of column A. When I changed the column A within the code to column I, it returned #ref when i ran the code. Then, I tried to move the data to column A, but that also didnt work and 0 were returned.
    Does anyone have any suggestions on what is going wrong?
    thanks so much

    Sarah

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Sarah

    How did you change the code?

  3. #3
    Registered User
    Join Date
    07-17-2007
    Posts
    13
    I think I figured out my problem but I don't know how to solve it.

    First, I just changed the code by substituting the correct column letter in this line:

    .Range("A2:A" & .Cells(Rows.Count, 1).End(xlUp).Row).Copy Destination:=Sheets("Summary").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)

    instead of column A2:A, my data is in column I2:I. The output was #REF values. However, the data in these columns (the I columns in each sheet) are cummulative distances and are a formula not just a value. When I copy paste special the value only, then the macro works.

    Is there anyway to incorperate this into the macro so it returns the value only?

    thanks!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Sarah,

    I modified Rylo's macro to paste only the values.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    07-17-2007
    Posts
    13
    That worked perfectly, thank you SO much

+ 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