Results 1 to 7 of 7

Thread: [RESOLVED] Copy column of items in clipboard to an array

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    20

    Re: Copy column of items in clipboard to an array

    That seems to be working great! Let me know if i could improve the code i have so far:

    Code:
    Public Sub ec_es_validation()
        Dim MyData As DataObject
        Dim myStr As String
        Dim myStrArray As Variant
        Dim i As Long
        
        Set MyData = New DataObject
        MyData.GetFromClipboard
        myStr = MyData.GetText(1)
        On Error GoTo Error_Handling
        
        myStrArray = Split(myStr, vbNewLine)
        
        For i = LBound(myStrArray) To UBound(myStrArray)
            Debug.Print myStrArray(i)
            'do more within For loop
    
        Next i
    
    ExitHere:
        Exit Sub
    
    Error_Handling:
        MsgBox "The clipboard is empty!", vbCritical
        Resume ExitHere
    
    End Sub
    Eventually i want to be able to search a worksheet by the myStrArray(i), if found, get the column its in paste that into a new spreadsheet.sheet1 "A - myStrArray(i)" / if not found it pastes a row on a new spreadsheet.sheet2 in the next unused row. id like the script to be smart enough to know "if spreadsheet is open, paste row on correct sheet, if not open, open excel instance and then paste."

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 2008
    Posts
    20

    Resolved [Resolved] Copy column of items in clipboard to an array

    I'll post further questions on my script in another post when needed. Thanks for your help westconn1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width