+ Reply to Thread
Results 1 to 14 of 14

Pulling data from a charging file!

  1. #1
    Registered User
    Join Date
    09-28-2007
    Posts
    7

    Pulling data from a charging file!

    I am relatively unexperienced with programming and I am having trouble with a few things here.
    I would like to be able to copy a single row of data from a huge sheet containing about 7000 rows on a daily basis. This would be a non issue except that it is not in the same row from day to day. It may be in row 1624 today and 1620 tomorrow basically. In the second column is a unique ID number that says constant though. I need a macro that can find this number and copy the entire row of data to another sheet.

    The second issue I am having is that this data is from a .csv file that is posted on the next business day. The name of this file changes day to day because the name of the file is the date it was from.

    If anyone can answer one or the other that would be great! I have been searching the forum for a week and have not found anything close enough for me to work with.

    Thank you very much for your help and time!!!
    Last edited by VBA Noob; 09-28-2007 at 12:52 PM.

  2. #2
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    I am not sure about the .csv file because I am relatively new to programming myself, but here is code that I think will work for your first issue:

    Range("B1").Select
    Dim UniqueID As String
    Dim RowNum As Integer
    UniqueID = SomeNumber
    RowNum = 1
    Do Until ActiveCell = ""
    If ActiveCell = UniqueID Then
    Rows(RowNum).Select
    Selection.Copy
    Sheets("Sheet2").Select
    ActiveSheet.Paste
    End
    Else
    ActiveCell.Offset(1, 0).Select
    RowNum = RowNum + 1
    End If
    Loop
    I went on some assumptions 1) The sheet to copy to is called "Sheet2" 2) The ID number could be anything.

    Hope this helps!

  3. #3
    Registered User
    Join Date
    09-28-2007
    Posts
    7
    Thank you very much! It does great at finding the cell, but it does not select the row? I have tried a few things now, but it does not want to select and copy the row. But that is a major step solved, again thank you very much!

    Andrew

  4. #4
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    It was working for me in the little example sheet I made when I was testing it. Did you look at Sheet2? Because the rows should be pasted into that sheet. If it is not working, attach your file and I will look at it.
    Last edited by wmorrison49; 09-28-2007 at 02:17 PM.

  5. #5
    Registered User
    Join Date
    09-28-2007
    Posts
    7
    I attached the actual file. I have been using sheet 3 to update from the web. I need the row to be copied from sheet three to sheet 2. I did edit the macro somewhat to include the ability to transpose so the rest works properly. I know the whole thing looks pretty ugly, but it is just a tool. I gutted a lot of the data other data out of sheet 3 to make the size small enough to send over, other wise that sheet is very large and very full.

    Basically what I currently have set up is for the data to be copied once I tell it which row it is in, and it copies to sheet 2 and is transpose. Then sheet 1 takes the data that I actually want to see from sheet 2 and updates the date, so copying the first row out of the data source is important. From there it is automatically entered into a archiver for trending and such.

    Again thank you so much for helping me out!
    Attached Files Attached Files

  6. #6
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    Sorry, this is a little too advanced from me being basically a VB rookie. Maybe you can modify the code from above that you said was working somewhat.

  7. #7
    Registered User
    Join Date
    09-28-2007
    Posts
    7
    Thank you very much anyway! Did you save your little trail spreadsheet? If you did please send it to me and I might be able to figure something out from it since you said it work for what you had it do!

  8. #8
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    I am am afraid I got rid of it. It was just words in column A and numbers in column B of Sheet1, then I ran the macro and the line in question got moved to Sheet2

  9. #9
    Registered User
    Join Date
    09-28-2007
    Posts
    7
    YIPPIE!! I did get it to work. Where you said "some number" there needed to be "" out side the number! GRRRR
    Because I Said So

  10. #10
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    Glad it's working for you, man. Sorry about the quotation mark issue, but good to know you worked it out.

  11. #11
    Registered User
    Join Date
    09-28-2007
    Posts
    7

    Angry Oh No!!!

    GRR! ME THROW COMPUTER THROUGH WINDOW!

    I lied, it did not work properly, I was accidentally using a macro that would select a very specific row based on its number, not by searching the for the ID number. I feel so stupid! I have done everything I could think of to it, and I still can not figure out why it will not select the row. As I mentioned before, it does find the cell with the data, which is a the biggest problem, but it still will not select the row the cell is in. I am so close now, this is the last snag in this sheet!

    Thank you for you help thus far though.

  12. #12
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    Feel free to attach the file again, what you are working with now. We'll figure it out

  13. #13
    Registered User
    Join Date
    10-01-2007
    Posts
    23
    Is this what you are looking for?

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    09-28-2007
    Posts
    7


    Absolutely Perfect! Thank you all so much!
    This forum is a life saver!

+ 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