+ Reply to Thread
Results 1 to 2 of 2

HELP! What's wrong with my code?

  1. #1
    Registered User
    Join Date
    07-11-2005
    Posts
    38

    HELP! What's wrong with my code?

    Hi,

    I have 2 workbooks. In the first workbook, I have a number of sheets each with their own account numbers. IN The second workbook ("text, shee1"), I have a listing of the account numbers along with revenues, expenses, and available balance next to each account. I am trying to match the account numbers in workbook1 with those in workbook2, and if they match, then to copy the info I need into workbook1. When I run the macro, it seems to be running ok with no errors. But then I notice that nothing has changed. Am i missing something here? Thanks in advance



    Sub ExtractData()

    Dim intRec As Integer, rngData As Range, rngItem As Range, rngComb As Range, rngOut As Range
    Dim mysht As Worksheet

    Application.ScreenUpdating = False

    For Each mysht In ThisWorkbook.Worksheets
    With mysht
    Set rngData = .Range("C33", .Range("C60").End(xlUp)).SpecialCells(xlCellTypeConstants)
    End With

    With Workbooks("text").Worksheets("sheet1")
    Set rngComb = Range("A1:A" & .Range("A65536").End(xlUp).Row)

    End With

    For Each rngItem In rngComb
    If rngItem = "stop" Then Exit Sub
    Set rngOut = rngData.Find(What:=rngItem)

    If Not rngOut Is Nothing Then
    rngOut.Offset(0, 2).Value = rngItem.Offset(0, 4).Value
    rngOut.Offset(0, 3).Value = rngItem.Offset(0, 5).Value
    rngOut.Offset(0, 4).Value = rngItem.Offset(0, 6).Value
    rngOut.Offset(0, 5).Value = rngItem.Offset(0, 7).Value
    Else
    End If
    Next rngItem
    Next mysht
    Application.ScreenUpdating = True

    End Sub

  2. #2
    Registered User
    Join Date
    07-11-2005
    Posts
    38
    nm, i got it.

    Set rngComb = Range("A1:A" & .Range("A65536").End(xlUp).Row)

    should be

    Set rngComb = .Range("A1:A" & .Range("A65536").End(xlUp).Row)



    wow, what a difference a period makes...

+ 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