+ Reply to Thread
Results 1 to 7 of 7

VBA searches for A B or C class column, cuts and pastes row and pastes to same workbook

  1. #1
    Registered User
    Join Date
    01-31-2019
    Location
    Australia
    MS-Off Ver
    2018
    Posts
    35

    VBA searches for A B or C class column, cuts and pastes row and pastes to same workbook

    Hi guys,

    Wanting to be able to enter Class (ABC) and Number of rows needed and to randomly find, cut and paste the row from A-D into K-N according to class and number of lines required to be cut and pasted.

    Any help would be appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: VBA searches for A B or C class column, cuts and pastes row and pastes to same workboo

    Try

    PHP Code: 
    Option Explicit
    Sub randClass
    ()
    Dim lr&, i&, j&, k&, c&, t&, clasrcri(), res(1 To 10001 To 4)
    Dim dic As Objectcell As Rangekey
    Set dic 
    CreateObject("Scripting.dictionary")
    lr Cells(Rows.Count"A").End(xlUp).Row
    clas 
    Range("A2:D" lr).Value
    Randomize
    For Each cell In Range("G2:I2")
        
    ReDim cri(1 To UBound(clas), 1 To 4)
        
    00
        
    For 1 To UBound(clas)
            If 
    clas(i1) = cell.Value Then
                k 
    1
                
    For 1 To 4
                    cri
    (kj) = clas(ij)
                
    Next
            End 
    If
        
    Next
        
    If 0 Then
            
    Do
                
    Int(Rnd k) + 1
                
    If Not dic.exists(rThen
                    dic
    .Add r""
                    
    11
                    
    For 1 To 4
                        res
    (tj) = cri(rj)
                    
    Next
                    Debug
    .Print rc
                    
    If cell.Offset(10).Value Then Exit Do
                
    End If
            
    Loop
        End 
    If
        
    dic.RemoveAll
    Next
    Range
    ("K2:N10000").ClearContents
    If 0 Then Range("K2").Resize(t4).Value res
    End Sub 
    Attached Files Attached Files
    Quang PT

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: VBA searches for A B or C class column, cuts and pastes row and pastes to same workboo

    Another option.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 03-21-2024 at 07:31 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Registered User
    Join Date
    01-31-2019
    Location
    Australia
    MS-Off Ver
    2018
    Posts
    35

    Re: VBA searches for A B or C class column, cuts and pastes row and pastes to same workboo

    Thanks so much guys, these are really good but I realize now that I need to cycle through and not repeat the selected SKU's

    So same as before but without repeating the same SKU's so A Class and B Class will be repeating while still working through C.

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: VBA searches for A B or C class column, cuts and pastes row and pastes to same workboo

    Actually, I still don't understand what your new request is. Can you mock up the result area manually and upload the file again?

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: VBA searches for A B or C class column, cuts and pastes row and pastes to same workboo

    Ref Post#3.
    There are no repetition. Pl verify once.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA searches for A B or C class column, cuts and pastes row and pastes to same workboo

    Quote Originally Posted by ManateeProfanity View Post
    not repeat the selected SKU's
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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 for when drop down menu = Closed, cuts entire line and pastes to another sheet
    By ManateeProfanity in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2021, 05:19 PM
  2. Replies: 0
    Last Post: 12-08-2014, 12:14 AM
  3. VBA Macro Code Problem - Cuts and Pastes Sheet Header - nightmare!
    By micropscotts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-06-2014, 03:25 PM
  4. Replies: 1
    Last Post: 10-03-2012, 07:06 PM
  5. Macro not working - Cuts and pastes rows of data from & into protected sheets
    By Christina75 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 12:03 PM
  6. Replies: 2
    Last Post: 09-05-2012, 03:20 PM
  7. How to stop #Ref! errors with macro that cuts and pastes from list
    By The Bantam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2009, 11:46 AM

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