+ Reply to Thread
Results 1 to 7 of 7

Copy values only

Hybrid View

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy values only

    Many thanks for this and apologies for the lack of code tags - totally new to the forum and didn't know how to do that (do now though cheers)

    This looks like should work, but the End If function now doesn't seem to work so just loops continuously?

    Dim i3 As Long, iMatches3 As Long
    Dim aTokens3() As String: aTokens3 = Split("Niche", ",")
    For Each Cell In Sheets("Data input").Range("a4:a9999")
        If (Len(Cell.Value) = 0) Then Exit For
            For i3 = 0 To UBound(aTokens3)
                If InStr(1, Cell.Value, aTokens3(i3), vbTextCompare) Then
                    iMatches3 = (iMatches3 + 1)
                    Sheets("data input").Rows(Cell.Row).Copy
                    Sheets("Niche Floor").Rows(iMatches3).PasteSpecial xlValues
                End If
            Next
    Next
    Any further suggestions to resolve this issue?

    Cheers

  2. #2
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy values only

    Actually from using F8, it appears to loop once it's gets to the second Next, and goes back to the If (Len.....) line, so this is the section that loops: -

        If (Len(Cell.Value) = 0) Then Exit For
            For i3 = 0 To UBound(aTokens3)
                If InStr(1, Cell.Value, aTokens3(i3), vbTextCompare) Then
                    iMatches3 = (iMatches3 + 1)
                    Sheets("data input").Rows(Cell.Row).Copy
                    Sheets("Niche Floor").Rows(iMatches3).PasteSpecial xlValues
                End If
            Next
    Next

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy values only

    Or use this line.

      If cell = vbNullString Then Exit For

  4. #4
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy values only

    Brilliant - think got it all sorted.

    Many thanks for your help AB33

+ 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. Replies: 8
    Last Post: 07-08-2013, 06:03 AM
  2. Need help making a macro to copy range of values based on cell values.
    By zolton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2013, 08:58 AM
  3. modify macro to copy values instead of copy and worbook instead of worsheet
    By sbab in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2013, 08:43 AM
  4. Replies: 0
    Last Post: 09-06-2012, 04:06 AM
  5. Replies: 10
    Last Post: 03-02-2006, 06:50 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