Hello all.
I have a little vba module that uses an external dll to automatically select a cell in one of the worksheets.
The user then enters a value into the cell and the external dll selects another cell. The user enters then a different value in the new selected cell.
This works pretty well. However, the values in the cells often only differ in the last one or two characters, which are usually numbers.
So, it would be great to let the user copy the first entered value and paste it into the next selected cell. But when I use Strg+V in the new cell nothing gets pasted. How would I enable copy paste?
Ideally, I would also like to set the cursor into the selected cell at the end of the pasted value. So that the user doesn't have to set the cursor manually.
Is this possible at all? I didn't find any setCursor function or something similar.
Any hints or tipps are appreciated.
Best regards,
heapifyman
I'm just thinking off the top of my head, but it may get you started.
In a Standard Module:
In the ThisWorkBook module:Public vOldValue
orPrivate Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range) vOldValue = Target.Value End Sub Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range) Target.Value = left(vOldValue,len(vOldValue)-2) End SubPrivate Sub Workbook_SheetSelectChange(ByVal sh As Object, ByVal Target As Range) Dim v If Target is Range("Cell2") then v = Range("Cell1").value v = Left(v,Len(v)-2) Target.Value = v End Fi End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks