PDA

View Full Version : Setting tab order, adding ability to stop/start code and refine functionality



MSXL
09-02-2022, 01:13 PM
I'm working on a concept to create an automatic clipboard, working from one sheet only.

First feature needed is to be able to set the tab order C7,C8,C9,C10,C11,C13,C16,C19,E7,E10,E13,G13,I13,E16,G16,I16,E19,C22 permanently regardless of whether any data is input into the existing cell. It should be possible to also click on a cell and when tab is pressed, it goes on to the next cell in this list following the selected cell. So for example, the user selects C13 and presses tab. It should then move on to C16.

Once the user is ready, code should start enabling a user to select any cell and automatically copy the contents to the clipboard. The user should be able to pause the code at any point to be able to paste data from elsewhere into the worksheet or type new data. I've added control buttons with the intention of those controlling start/stop.

At the moment, I have it working in part and have attached a copy so you can see what I am working with.

You will see that currently using tab messes up what is copied to the clipboard, clicking on a cell doesn't work as expected and for reasons I cannot fathom, it does not ever tab through to C22.

https://drive.google.com/file/d/1PobGUO5avY3zxcz1llPd9UnI6-dMSIrI/view?usp=sharing

Thank you for your help.

arnelgp
09-02-2022, 08:11 PM
what i worked on was the Tab/ Shift-Tab.
you need to add code for the Clipboard thing.

MSXL
09-02-2022, 11:29 PM
Thank you for your reply. I tried testing the attached and when I pressed tab, it immediately came up with an error:

Tun-time error '13':
Type mismatch

For i = 0 To UBound(arr)

arnelgp
09-02-2022, 11:33 PM
obviously the code in Thisworkbook Open did not fire-up.
close the workbook first.
upon opening, if you see any Macro Warning, (yellow band) just enable it.

arnelgp
09-02-2022, 11:49 PM
here i select $C$7 first on Clipboard sheet.
then, you can Tab/Shift tab.

MSXL
09-03-2022, 12:25 AM
Thank you, that's awesome. You even considered back tabbing, which I hadn't.

I'm not sure how to re-introduce the automatic copy functionality, as trying to reinsert the code where it was or even reducing it to "Target.Copy" after module1 brings up an error within module1

Clipboard code:

If Not Intersect(Target, Range("C7,C8,C9,C10,C11,C13,C16,C19,E7,E10,E13,G13,I13,E16,G16,I16,E19,C22")) Is Nothing Then Target.Copy
End If


Error line with mismatch:

strAddress = arr(0)

MSXL
09-03-2022, 12:37 AM
Rethinking it, this is what I have come up with:


Option Explicit

Public arr As Variant
Public strAddress As String


Public Sub ProcessTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = UBound(arr) Then
i = 0
Else
i = i + 1
End If
Exit For
End If
Next
ActiveSheet.Range(arr(i)).Select
ActiveSheet.Range.Copy
Else
strAddress = arr(0)
End If
End Sub




Public Sub ProcessBkTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = 0 Then
i = UBound(arr)
Else
i = i - 1
End If
Exit For
End If
Next
ActiveSheet.Range(arr(i)).Select
ActiveSheet.Range.Copy
Else
strAddress = arr(0)
End If
End Sub


I think it might be best to change ActiveSheet to the worksheet name so it doesn't throw an error if the user switches between workbooks.

It's coming back up with the same mismatch error when trying to select different cells or tabbing now.

https://drive.google.com/file/d/1BuTw372Xg48bGZ6Dlk0VAhPAqTpPtWq2/view?usp=sharing

MSXL
09-03-2022, 12:41 AM
Changing to the worksheet name doesn't work:


Option Explicit

Public arr As Variant
Public strAddress As String


Public Sub ProcessTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = UBound(arr) Then
i = 0
Else
i = i + 1
End If
Exit For
End If
Next
Worksheets("Clipboard").Range(arr(i)).Select
Worksheets("Clipboard").Range(arr(i)).Copy
Else
strAddress = arr(0)
End If
End Sub




Public Sub ProcessBkTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = 0 Then
i = UBound(arr)
Else
i = i - 1
End If
Exit For
End If
Next
Worksheets("Clipboard").Range(arr(i)).Select
Worksheets("Clipboard").Range(arr(i)).Copy
Else
strAddress = arr(0)
End If
End Sub

MSXL
09-03-2022, 01:10 AM
Seems to work until try clicking a cell, the focus doesn't change to that cell and the clipboard remains on the last selection made by tabbing.

MSXL
09-03-2022, 01:36 AM
Modifying the VBA on the worksheet Clipboard seems to fix this.


Private Sub Worksheet_SelectionChange(ByVal Target As Range) Module1.strAddress = Target.Address
Target.Copy
End Sub

Now need to figure out how to disable automatic copying using the buttons to allow user to paste data from an external source or type it in and tab without copying.

Also, trying to avoid empty cells from being copied when automatic copying is enabled.

MSXL
09-03-2022, 01:48 AM
Thought this might be a partial solution but it didn't make any difference:


Private Sub Worksheet_SelectionChange(ByVal Target As Range) Module1.strAddress = Target.Address
If Not IsEmpty(Target.Address) Then
Target.Copy
End If
End Sub

arnelgp
09-03-2022, 01:52 AM
why do you need to have the Clipboard involve, when you can Reference any cell and check if it has value.
then you assign the value to an array/variable.

when it is time to "paste" just read out from the variables.

EDIT:

what does the "play", "pause", "refresh" buttons need to do?
maybe i can help you out, without the Clipboard thing.

MSXL
09-03-2022, 02:00 AM
Thought it might be something to do with needing to introduce similar in the module but unsure how to phrase what should be inserted in brackets. I tried a few things and none of them worked including "Range(arr(i))"


Option Explicit

Public arr As Variant
Public strAddress As String


Public Sub ProcessTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = UBound(arr) Then
i = 0
Else
i = i + 1
End If
Exit For
End If
Next
Worksheets("Clipboard").Range(arr(i)).Select
If Not IsEmpty() = True Then
Worksheets("Clipboard").Range(arr(i)).Copy
End If
Else
strAddress = arr(0)
End If
End Sub




Public Sub ProcessBkTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = 0 Then
i = UBound(arr)
Else
i = i - 1
End If
Exit For
End If
Next
Worksheets("Clipboard").Range(arr(i)).Select
If Not IsEmpty() = True Then
Worksheets("Clipboard").Range(arr(i)).Copy
End If
Else
strAddress = arr(0)
End If
End Sub

MSXL
09-03-2022, 02:04 AM
Thanks for your reply. The play button is for VBA to loop continuously providing the clipboard automatically copying functionality, the pause button is to allow users to type or "paste special-value" text into the cells without the VBA loop interrupting. The refresh button is to clear all the cells of values.

MSXL
09-03-2022, 02:06 AM
It might be worth me explaining that the main and original idea was to be able to click any cell that contains data and have it automatically copy to the clipboard, so that it can be pasted quickly to another application.

arnelgp
09-03-2022, 02:54 AM
here check and test again those 3 buttons.

MSXL
09-03-2022, 05:18 AM
w00t! I've played with it a little bit and it seems to work exactly as I had imagined. I have no idea how you did that! Thank you. I will let you know if I come across any issues.

MSXL
09-03-2022, 05:27 AM
Is there a way to insert the words "Input Mode" in the space between the pause and undo buttons when the worksheet first opens or pause is pressed and "Copy Mode" when the play button is pressed (centred in I3).

arnelgp
09-03-2022, 05:57 AM
here i added "Status" rectangle shape.

MSXL
09-03-2022, 06:00 AM
In the mean time, I have added the following to Clipboard VBA


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Cancel = True
MsgBox ("To paste data, press ""Ctrl"" & ""V""."), _
vbInformation, "Automatic Clipboard"
End Sub


Sub PasteasValue()
Selection.PasteSpecial Paste:=xlPasteValues

Within Module1, I'd like to add a prompt "Are you sure you want to clear all the data? Yes/No.

If yes, clear. If no, cancel.

I figure that would go in here.


Public Sub ClipClear()
Call ClipOff
Sheet10.Range("$C$4") = Null
End Sub


vbYesNo with default button No vbDefaultButton2.

MSXL
09-03-2022, 06:46 AM
That's brilliant, thank you. Is it possible to alternate the text colour? Green for Input and Red for Copy Mode.

MSXL
09-03-2022, 08:23 AM
This brings up the prompt but cancel doesn't stop the procedure.


Public Sub ClipClear()
Call ClipOff
MsgBox "Are you sure you wish to clear the data?", vbQuestion + vbYesNo + vbDefaultButton2, "Automatic Clipboard"
Sheet10.Range("$C$4") = Null
End Sub

MSXL
09-03-2022, 09:17 AM
Okay, this is the solution.


Public Sub ClipClear()Dim Answer As Integer
Answer = MsgBox("Are you sure you wish to clear the data?", vbQuestion + vbYesNo + vbDefaultButton2, "Automatic Clipboard")
If Answer = vbYes Then
Call ClipOff
' MsgBox "Cleared"
Sheet10.Range("C7,C8,C9,C10,C11,C13,C16,C19,E13,G13,I13,E16,G16,I16").ClearContents
Sheet10.Range("E7:I7").ClearContents
Sheet10.Range("E10:I10").ClearContents
Sheet10.Range("E19:I19").ClearContents
Sheet10.Range("C22:I22").ClearContents
Sheet10.Range("$C$4") = Null
Else
'Do nothing
End If
End Sub

I'd still like the message to show as green or red as described previously.

MSXL
09-03-2022, 10:20 AM
I think I have figured it out, is this how you would do it?


Public Sub ClipOn()
Dim thisAddress As String
thisAddress = Split(strAddress, ":")(0)
With Sheet10
.IsClipRunning = True
' unprotect and change the color of the "play" button to red (or you may use any color)
.Unprotect
.Shapes("Status").TextFrame.Characters.Text = "Copy Mode"
.Shapes("Status").TextFrame.Characters.Font.Color = vbRed
.Shapes("Button 33").TextFrame.Characters.Font.Color = vbRed
.Protect
If Len(Trim$(.Range(thisAddress).value & "")) Then
Call putToClipboard(.Range(thisAddress).value)
End If
End With
End Sub

Public Sub ClipOff()
With Sheet10
' unprotect to re-instate the color of "play" button to black
.Unprotect
.Shapes("Status").TextFrame.Characters.Text = "Input Mode"
.Shapes("Status").TextFrame.Characters.Font.Color = RGB(146, 208, 80)
.Shapes("Button 33").TextFrame.Characters.Font.Color = vbBlack
.IsClipRunning = False
.Protect
End With
End Sub

MSXL
09-03-2022, 10:42 AM
I'm trying to change the background colour but cannot get the syntax correct.


.Shapes("Status").TextFrame.Fill.BackColor.RGB = RGB(146, 208, 80)

How do I define the background colour of this textframe please?

arnelgp
09-03-2022, 10:18 PM
here again your workbook.

MSXL
09-04-2022, 12:32 AM
Thank you very much, you have been so helpful.

snb
09-04-2022, 02:02 AM
Identical functionality:


Buttons(2).Font.Color = 255
Shapes("Button 33").TextFrame.Characters.Font.Color = vbRed

MSXL
09-04-2022, 04:47 AM
Thanks snb.

@arnelgp

Ah, some functionality is missing and I had assumed it was there before. The idea behind this worksheet is that pressing play not only displays the last cell selected containing data, it also automatically copies it to the Windows clipboard.

Is that an easy feature to add now that we have start/stop functionality? If so, what additional code is required/where please?

MSXL
09-04-2022, 05:48 AM
Is this the best way?

Modify the putToClipboard code:

Public Function putToClipboard(ByVal theValue As Variant)
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
.SetText theValue
Sheet10.Range("$C$4") = theValue
End With
Sheet10.Range("$C$4").Copy
End Function

arnelgp
09-04-2022, 06:00 AM
forgot to PutInClipboard:


Public Function putToClipboard(ByVal theValue As Variant)
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
.SetText theValue & ""
.PutInClipboard
End With
Sheet10.Range("$C$4") = theValue
End Function

MSXL
09-04-2022, 06:48 AM
Thank you so much.


forgot to PutInClipboard:


Public Function putToClipboard(ByVal theValue As Variant)
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
.SetText theValue & ""
.PutInClipboard
End With
Sheet10.Range("$C$4") = theValue
End Function

MSXL
09-04-2022, 09:15 AM
I have just tried using another workbook open at the same time and it's producing errors:

http://www.vbaexpress.com/forum/image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVAAAADgCAYAAABVVT4YAAAWoklEQVR4nO3dTYgb 6Z3H8V8ZQ5Yl2U1CLiGH9oCUxmYaDO1LlyHGGRiQ7EPjgw5z8BgfJPawuDRgyMAYu7HBgYaRTA5 L62A8PgxsH0wf2hIEJoMXRn3pBoPNGI80uBs25BLYBJZlYUNqD3rpklQlVT16qSr7 wHhRKpSPU 9/Or/PCV7LMdxXAEAIjspSZVKJe52AECqlMtlnYi7EQCQVgQoABgiQAHA0Invvv/3uNsAAKl04kc/iLsJAJBODOEBwNCJH/3gZ3G3AQBS6cQPf/DPcbcBAFLphP7pXNxtAIBUYg4UAAwRoABgiAAF8NawLEsHBwcTlzs4OJBlWVNvL1KANkqWLOu8H rQDl1DJsmSVGkPrlNQIWiUB2g/Oy7LCt7NRGuxj0GeL6nujZOl88EHx9O/4NW75qNuepo9R973BFvTgvCXr/APNpsf ho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lZv69lQleo/V/1ag1l5qDevpeX3kj2vPWsEaEok82I peuf35Y2Loz8xvDw4RVd2JBuf35dfpfUxfvPdFsbuhDqN4jxSORNa54ufqiPDjb0SainQQfa2Do docPP9GGbquU/KntmeJfpE JxF7Mp67rydGv9fDKBS1teN5fva1nR/7h2V1R1588UmvpmpZe39azJ OWjcfZs2eld pfpL o 0eP9OmS91h pEdHnrlOed7/8PdaWrrmWS55x3DeCNCU6P1nJpLplK4/OdL1CUtdvH80dCFe1P2jI92fX8Om8vz58/6/SJ92o/u 49T1JzoaXDLgmFzU/aOhb7h4X0dHST16i8EQPiWSG55vr2ROmyBJCNCU4GJePG5amIQATQku5sXjphXkou77zou ewjQlOBiXjxuWpiEAE0JLubF46aFSQjQlOBiXjxuWpiEAE2J58 f90OUPxf7JxDEchzHvXPnTtztQIAf//ZPcTcBkv7ym59HWv6rr77SuXPn5tQahLG/v68PPvhgbt9/584dfkgPzMv /n7cTcCcEaAJF7XyQTLMs/JBcjAHCgCGCFAAMESAAoAhAhQADBGgAGCIAAUAQwQoABgiQAHAEAEKAIYIUAAwRIACgCECFAAME aAAYIgABQBDluM4btyNAIA0 n 7k7dOr7baDQAAAABJRU5ErkJggg==


Private WithEvents oCbarEvents As CommandBars

How can this be resolved?

MSXL
09-04-2022, 11:02 AM
Ah, the error message image didn't attach.

30122

MSXL
09-04-2022, 12:18 PM
It appears to be something to do with any worksheet containing "Private Sub Worksheet_Change(ByVal Target As Range)" as that's when the error occurs, when switching between sheets in another open workbook.

For example:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("C4"), Target) Is Nothing Then
If Range("C4").Value = "" Then
Application.EnableEvents = False
Range("C4").Value = "'Choose"
Application.EnableEvents = True
End If
End If
End Sub


My workbooks contain a lot of these types of events so I need to know how to avoid this error and have everything continue to work normally.

snb
09-05-2022, 01:20 AM
Private Sub Worksheet_Change(ByVal Target As Range)
If target.address & target ="$C$4" Then
Application.EnableEvents = False
target = "Choose"
Application.EnableEvents = True
End If
End Sub

You'd better use a Userform.

MSXL
09-05-2022, 02:46 AM
Private Sub Worksheet_Change(ByVal Target As Range)
If target.address & target ="$C$4" Then
Application.EnableEvents = False
target = "Choose"
Application.EnableEvents = True
End If
End Sub

You'd better use a Userform.

Surely there must be another way that doesn't require building from the ground up, when this is so close? I wouldn't know where to start and I don't know whether the functionality of this clipboard would work inside a userform.

Aussiebear
09-05-2022, 05:03 AM
This is rapidly becoming a rather complex issue. Normally a thread composes a singular question. Msxl from here on in, single questions only otherwise start a new thread.

MSXL
09-08-2022, 09:57 AM
Okay, let's try again. I'm occasionally getting an error with the following:


Option Explicit

Public arr As Variant
Public strAddress As String


Public Sub ProcessTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = UBound(arr) Then
i = 0
Else
i = i + 1
End If
Exit For
End If
Next
ActiveSheet.Range(arr(i)).Select
Else
strAddress = arr(0)
End If
End Sub


Public Sub ProcessBkTab()
Dim i As Integer
If Len(strAddress) <> 0 Then
For i = 0 To UBound(arr)
If arr(i) = Split(strAddress, ":")(0) Then
If i = 0 Then
i = UBound(arr)
Else
i = i - 1
End If
Exit For
End If
Next
ActiveSheet.Range(arr(i)).Select
Else
strAddress = arr(0)
End If
End Sub

In Sub ProcessTab, it's specifically this code that throws the error:

Run-time error '13': Type mismatch

ActiveSheet.Range(arr(i)).Select

strAddress = arr(0)

Run-time error '9': Subscript out of range

thisAddress = Split(strAddress, ":")(0)

I'm not sure what causes it, except that it's related to pressing TAB.

https://drive.google.com/file/d/1yL0pli6b1ymMZe33An2XLnG5U2J3ddQs/view?usp=sharing

MSXL
09-13-2022, 02:33 PM
here again your workbook.http://www.vbaexpress.com/forum/showthread.php?70202-Setting-tab-order-adding-ability-to-stop-start-code-and-refine-functionality&p=416601&viewfull=1#post416601

I've been testing and come across a problem with text being copied to the clipboard being unreadable

Here is the output in Notepad++

30151

In Notepad it shows nothing.

I don't understand. So, I went back to the version that you shared and it's doing the same thing as the Notepad++ screenshot.

Does this happen for anyone else who tries the quoted download? What could be the cause?

MSXL
09-14-2022, 12:03 PM
I've noticed that this seems to work fine in Office 2013 on Windows Server 2012 RS 64 Bit, but it's not working in Office 2019 on Windows 10 Home 64 bit. Any ideas?