+ Reply to Thread
Results 1 to 9 of 9

Thread: macro to copy range of cells to another sheet

  1. #1
    Registered User
    Join Date
    10-14-2011
    Location
    chesapeake, va
    MS-Off Ver
    Excel 2007
    Posts
    8

    macro to copy range of cells to another sheet

    i am new to VBA, i've searched an have been unable to locate exactly what it is i need. i'm trying to find a specific value "NAME" on sheet(Roster) then copy a range of cells (located value say A18 through end of list(end of the list will vary) say the end is J94) to another worksheet(Student Info) starting at say A8

    Any Help in this matter would be greatly appriciated, i've come very close in many ways, but never quite right, thanks again for anyone who has the time.

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,299

    Re: macro to copy range of cells to another sheet

    Sure, we are here to help you out. Can you attach a sample workbook so its easier to understand what you need?

  3. #3
    Registered User
    Join Date
    10-14-2011
    Location
    chesapeake, va
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: macro to copy range of cells to another sheet

    Need to clean the data
    Last edited by Spyderz; 10-14-2011 at 11:19 AM. Reason: posted incorrectly

  4. #4
    Registered User
    Join Date
    10-14-2011
    Location
    chesapeake, va
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: macro to copy range of cells to another sheet

    First off, thank you for the quick response. this is the workbook in question, along with a cleaned( of sensative Data) template of the data i'm importing. i will add a sheet Student info, where i will then copy the infoi'm searching for to, then i plan to link all the other documents to that sheet. the text doc doesn't have a very standard format, i thought this would be the best approach. thanks again for what ever help you are able to provide.
    Attached Files Attached Files

  5. #5
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,299

    Re: macro to copy range of cells to another sheet

    The file you attached doesn't have the tab "Student Info". Even after seeing the attachments, i am not able to understand what the problem is.

  6. #6
    Registered User
    Join Date
    10-14-2011
    Location
    chesapeake, va
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: macro to copy range of cells to another sheet

    Quote Originally Posted by arlu1201 View Post
    The file you attached doesn't have the tab "Student Info". Even after seeing the attachments, i am not able to understand what the problem is.
    The student Info will be added, and the macro to copy the range of cells will copy to the Student Info sheet, the problem comes when the Data is refreshed from the Text doc, on a few occasions, there are extra line spaces added to the text doc, so the data that the other sheets link to do not line up appropriately. so i thought that copying a range from the imported data starting at the cell where the text NAME was found to a new sheet would ensure that all references to the new sheet will always be in the correct order.
    i will rewrite the formulas of the other sheets to match the Student Info sheet once created
    Attached is the file with the New Sheet, yet is still blank
    Attached Files Attached Files
    Last edited by Spyderz; 10-19-2011 at 04:03 PM.

  7. #7
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,299

    Re: macro to copy range of cells to another sheet

    So ideally, we need to copy data from the text file and put it into excel right? And the copy has to be done from the right row onwards so that the other sheets dont get misaligned

  8. #8
    Registered User
    Join Date
    10-14-2011
    Location
    chesapeake, va
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: macro to copy range of cells to another sheet

    Quote Originally Posted by arlu1201 View Post
    So ideally, we need to copy data from the text file and put it into excel right? And the copy has to be done from the right row onwards so that the other sheets dont get misaligned
    Thats right, preferably starting at the line with the word "NAME" in the cell, and ending at the last name in the formatted feilds, the class size hcanges regularly. then i can run other more specific searches to populate the class number ext. but unless i get the Names right, then its somewhat usless. Thanks again for your help, i'm certain its simple, i'm just learning at this point.

  9. #9
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,299

    Re: macro to copy range of cells to another sheet

    I have got this code which enables you to copy data starting from "Name" only.
    
    sub import_data()
    Workbooks.OpenText Filename:="D:\Test\TEST ROSTER.txt", Origin:=437, _
            StartRow:=19, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
            ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, Comma:=False _
            , Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array _
            (3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array( _
            10, 1), Array(11, 1), Array(12, 1), Array(13, 1)), TrailingMinusNumbers:=True
    
    end sub
    Change the path in this code to reflect your path where the file is stored.
    There was no specific delimiter i could use, so i used the space delimiter, which resulted in the data getting segregated into many columns. Please provide me a sample of what the data should be under each heading and i can help you with the code to get it sorted out.

+ 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.2.0