+ Reply to Thread
Results 1 to 6 of 6

Macro - VBA

  1. #1
    Registered User
    Join Date
    12-15-2005
    Posts
    12

    Macro - VBA

    How do i change this macro, so it would go through the whole sheet1 instead of the first set of data. The data on sheet1 has data of 80 different accounts, every set of data includes the account number, balance, and activity. I would like my macro to go through sheet1 locate "account number:" in column A then copy the account number which is located in column C and copy the balance thats located in column H and past them in sheet 2 starting with row2.

    Sub Demo()
    Dim LstRw As Long, ThisRw As Long
    LstRw = Cells(Rows.Count, "A").End(xlUp).Row

    For ThisRw = 1 To LstRw
    If Cells(ThisRw, "A").Value = "Bank Account Number" Then
    Sheets("Sheet2").Cells(ThisRw, "A").Value = Cells(ThisRw, "C").Value
    Sheets("Sheet2").Cells(ThisRw, "B").Value = Cells(ThisRw, "H").Value
    End If
    Next ThisRw

    End Sub

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Can the account number occur more than once in column A? If so:

    Please Login or Register  to view this content.
    If it can only occur once, put "exit for" after the second .copy command.


    HTH
    Col
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  3. #3
    Registered User
    Join Date
    12-15-2005
    Posts
    12
    thats not what im looking for.

    In the file attached you will notice all the data in sheet1 containing account number, account balance, and activity. i need the macro to go through all that data and copy the date, account number, and account balance then paste it in sheet2. placing the date in column A, account number in column B, and amount in column C. listing all of the accounts.
    Attached Files Attached Files

  4. #4
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Fairy nuff.

    This ought to do the trick then:

    Please Login or Register  to view this content.

    C

  5. #5
    Registered User
    Join Date
    12-15-2005
    Posts
    12
    This is not pulling the correct data, the attached example has the data pulled after running the macro and the data i would like it to pull on sheet2. Help


    Quote Originally Posted by colofnature
    Fairy nuff.

    This ought to do the trick then:

    Please Login or Register  to view this content.

    C
    Attached Files Attached Files

  6. #6
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Please Login or Register  to view this content.

+ 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