Results 1 to 12 of 12

First time coding in VB, no errors but my very simple script isn't working. Help?

Threaded View

  1. #1
    Registered User
    Join Date
    02-16-2012
    Location
    California (CA)
    MS-Off Ver
    Excel 2011
    Posts
    6

    First time coding in VB, no errors but my very simple script isn't working. Help?

    My boss asked me to pull some data from a big Excel spreadsheet. Basically she has two files, one of them has A, a one-dimensional list of experimental trials, and the other file has a worksheet B where column 1 corresponds to the names of the trials, and the rest of the columns have values for other attributes of the data. Presumably all the names in A are in B as well, but the script should accomodate it if that's not the case.

    I want to take all the data from the columns of B whose value in the first row match the names from A, and paste those rows into a sheet C. Here's what I wrote:



    Sub PullData()
    For X = 1 To X = 100
    
    Application.Goto Workbooks("A_Data.xls")
    
    DataName = Workbooks("A_Data.xls").Sheets("Sheet1").Cells(X, 1)
    
    Application.Goto Workbooks("B_Data.xls").Sheets("Sheet1").Range("A1:A1000")
    
    
    Selection.Find(what:=ContNum, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False).Acivate
    
    targetrow = ActiveCell.Row
    Rows(targetrow, targetrow).Select
    Selection.Copy
    
    Application.Goto Sheets("C").Cells(X, 1)
    Selection.Paste
    
    Next X
    
    End Sub
    ----------------

    When I run this, it doesn't actually do anything. I don't get any errors, but I don't get any output either. Obviously I'm missing something. If I'm being unclear about anything, please let me know and I'll try to explain it better.
    Any suggestions would be greatly appreciated!
    Last edited by metajellyfish; 02-16-2012 at 09:41 PM.

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