Good evening all,
I'm trying to make a program that will allow the user to click on a cell or select multiple cells and the contents of that cell, or a selection of cells, will then be pasted into another workbook. I'm using a selection change event to accomplish this. It works fine until I try to get it to paste into another workbook...then not so fine. Any thoughts would be appreciated.
I'm trying to make a program that will allow the user to click on a cell or select multiple cells and the contents of that cell, or a selection of cells, will then be pasted into another workbook. I'm using a selection change event to accomplish this. It works fine until I try to get it to paste into another workbook...then not so fine. Any thoughts would be appreciated.
Rich (BB code):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim wb1 As Workbook, wb2 As Workbook, shxx As Worksheet, shx As Worksheet
Set wb1 = ActiveWorkbook
Set wb2 = Workbooks(2)
Set shx = wb1.Sheets(1)
Set shxx = wb2.Sheets(1)
Cells.Interior.ColorIndex = 0
If IsEmpty(Target) Or Selection.Cells.Count > 10 Then Exit Sub
Application.ScreenUpdating = False
With Selection
Range(Selection, Selection.Offset(0, 1)).Select
Range(Cells(.Row, .CurrentRegion.Column), _
Cells(.Row, .CurrentRegion.Columns.Count + .CurrentRegion.Column - 1)) _
.Interior.Color = vbCyan And Selection.Copy
Application.EnableEvents = False
shxx.Range("J65536").End(xlUp).Offset(1, 0).Select
shxx.Paste
Application.EnableEvents = True
End With
Application.ScreenUpdating = True
End Sub