Hi,
Got a right old problem here and have been racking my brain but cannot come up with an answer, or at least an answer I can code!
I currently have some code which moves a button about on a spreadsheet to be in line with whatever row is selected. See here:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A" & Target.Row).Value <> "" ]Then
With ActiveSheet
.CommandButton1.Top = ActiveCell.Top + (((ActiveCell.Height) / 2) - (CommandButton1.Height / 2))
End With
End If
End Sub
It works great, the problem is, if I select a cell and copy it, as soon as I move to the cell I want to copy it to, an unitentional consequence of the code above causes the previous cell to become not available for copying, might clear the clipboard, not sure.
So I can't find a method to reference the previously selected cell(can't get Application.PreviousSelections to work) and I'm pretty sure there's not a method to check if the clipboard has just had something pasted to it.
I was going to get the last cell's value, check it against the clipboard and if they were the same, after the code had completed I was going to put the data back into the clipboard but like I said, can't get Previous Cell value.
Also, I'm not sure if this will work since I think Ctrl-C and paste from menu relys on the cell still having the moving box(very technical I know) around it.
Any ideas?
Cheers,
Pete
Got a right old problem here and have been racking my brain but cannot come up with an answer, or at least an answer I can code!
I currently have some code which moves a button about on a spreadsheet to be in line with whatever row is selected. See here:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A" & Target.Row).Value <> "" ]Then
With ActiveSheet
.CommandButton1.Top = ActiveCell.Top + (((ActiveCell.Height) / 2) - (CommandButton1.Height / 2))
End With
End If
End Sub
It works great, the problem is, if I select a cell and copy it, as soon as I move to the cell I want to copy it to, an unitentional consequence of the code above causes the previous cell to become not available for copying, might clear the clipboard, not sure.
So I can't find a method to reference the previously selected cell(can't get Application.PreviousSelections to work) and I'm pretty sure there's not a method to check if the clipboard has just had something pasted to it.
I was going to get the last cell's value, check it against the clipboard and if they were the same, after the code had completed I was going to put the data back into the clipboard but like I said, can't get Previous Cell value.
Also, I'm not sure if this will work since I think Ctrl-C and paste from menu relys on the cell still having the moving box(very technical I know) around it.
Any ideas?
Cheers,
Pete