+ Reply to Thread
Results 1 to 9 of 9

Change code to search amount.

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Change code to search amount.

    HI I have below code which search in column J for the amount. and when find it copy the rows to sheet 3, which have this amount.
    I need 2 changes.
    First i need to when i search and it copy to sheet 3. If i search again for other amount. i need it to not overwrite the all ready found rows but continue in the next blank row
    in sheet 3.

    The next i need is a change in the amount of rows. Its like this code can only work with the 65536 rows even if the workbook is saved as a xlsm in excel 2013.
    I need the range to be made so it can search in big sheets. This line i need to be changed

    #lastline = Range("A65536").End(xlUp).Row#




    Here is the full code. Please have a look.

    Sincerely

    Abjac

    P.s i cant put anything around the code. Like the option is not there i tried put manually in, but its not working the option to make bold and the other is not there now.

    #Sub customcopy()
    Sheets(2).Activate
    Dim strsearch As String, lastline As Integer, tocopy As Integer
    linestart:
    strsearch = CStr(InputBox("enter the amount to search for"))
    lastline = Range("A65536").End(xlUp).Row
    j = 2
    For i = 1 To lastline
    ' Can search in more than one column. Change the range example A instead of J and second J,
    ' will search in column A to J then below example only in column J
    For Each c In Range("J" & i & ":J" & i)
    If InStr(c.Text, strsearch) Then
    tocopy = 1
    End If
    Next c
    If tocopy = 1 Then
    Rows(i).Copy Destination:=Sheets(3).Rows(j)
    j = j + 1
    ffound = ffound + 1
    End If

    tocopy = 0

    Next i
    If ffound = 0 Then
    MsgBox "Not found, Try again"
    GoTo linestart
    End If
    End Sub#
    Last edited by abjac; 05-30-2016 at 06:12 AM.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,522

    Re: Change code to search amount.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,522

    Re: Change code to search amount.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Change code to search amount.

    HI Thanks bakerman i checked the changes. The first one is giving me the error overflow.- So its not working.
    The second works perfect it continue the search in the next free row. So thats perfect.-
    But first one have some kind of error.
    Please have a look

    Thanks
    Abjac

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,522

    Re: Change code to search amount.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Change code to search amount.

    That made the big difference. Thanks allot Bakerman2 really great and fast help. Have a nice day

    Sincerely
    Abjac

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,522

    Re: Change code to search amount.

    Glad to help and thanks for the rep.

  8. #8
    Registered User
    Join Date
    09-07-2016
    Location
    Amsterdam
    MS-Off Ver
    2013
    Posts
    1

    Re: Change code to search amount.

    I got it right also, needed some modification on dim long
    Last edited by liisi; 09-07-2016 at 04:55 PM.

  9. #9
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Change code to search amount.

    Thanks liisi. Long time since i posted this but nice to get help. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Code - Search text & search number & search qty and result - Urgent Please
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2014, 10:51 AM
  2. Sum charge amount every time the code and the order number change
    By children in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-19-2013, 08:49 AM
  3. Create Search in column E for amount.Patel 45 your original code
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-28-2012, 03:51 PM
  4. search change code
    By qwzx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2011, 05:19 AM
  5. Replies: 6
    Last Post: 05-11-2011, 04:40 PM
  6. Search data for largest amount
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-17-2009, 06:05 PM
  7. Sumproduct formula:Empl Code Payroll Code Amount
    By bluemeg in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-30-2009, 02:08 PM

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