View Single Post
 
Old 05-08-2017, 07:58 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming the workbook is open at the sheet you want to process then

Code:
Private Sub CommandButton2_Click()
Dim objXL As Object
Dim NumRows As Long
Dim xlsNextRow As Long
Dim xlSheet As Object
    If Len(Selection) > 1 Then
        Set objXL = GetObject(, "excel.application")
        Set xlSheet = objXL.activesheet
        xlsNextRow = xlSheet.Range("B" & xlSheet.Rows.Count).End(-4162).Row + 1
        xlSheet.Cells(xlsNextRow, 2) = Selection.Text
    Else
        MsgBox "Nothing selected"
    End If
    Set objXL = Nothing
    Set xlSheet = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote