I'm having a hard time making this code do what I want it to. Basically, an inkEdt control displays sheet row data, rows C2:C6 on Sheet MATT24. The code as is
copies every row separated by carriage return spaces for easier reading. The problem with this code the way it is now, is that it only colors the text string of the first row, cell C2 of the sheet. To work right, it should color the text string between quotes of every row displayed on the sheet = C2:C6. The image shows the result of what
this code does.
Its only performing the string text coloring operation on the first row = C2. It should color all text strings between quotes from C2:C6.
It may be because of the carriage return spacing I put in the code. At any rate, I can't figure out where the problem is. It also colors
the rest in vbBlue.
Can anyone help to see where the problem in the code is?
Thanks very much for anyone's help.
cr
copies every row separated by carriage return spaces for easier reading. The problem with this code the way it is now, is that it only colors the text string of the first row, cell C2 of the sheet. To work right, it should color the text string between quotes of every row displayed on the sheet = C2:C6. The image shows the result of what
this code does.
Code:
Private Sub cmdRUN3_Click()
Dim i As Long, r As Range
Dim intCount As Integer, n As Integer
Dim lngPos1 As Long, lngPos2 As Long
For i = 0 To Me.ListBox2.ListCount - 1
Row = Me.ListBox2.List(i) ' current row to process
inkText.Text = inkText.Text + Row & vbCrLf & vbCrLf
GoSub color
Next i
Exit Sub
color:
Dim strIn As String
'inkText.Text = Sheets("MATT24").Range("C2")
strIn = Sheets("MATT24").Range("C2")
intCount = Len(strIn) - Len(Replace(strIn, """", ""))
lngPos1 = 1
With Me.inkText
.SelLength = Len(inkText)
.SelColor = vbBlue
.SelLength = 0
End With
For n = 1 To intCount Step 2
lngPos1 = InStr(lngPos1, strIn, """")
lngPos2 = InStr(lngPos1 + 1, strIn, """") - 1
With Me.inkText
.SelStart = lngPos1
.SelLength = lngPos2 - lngPos1
.SelColor = vbRed
.SelLength = 0
End With
lngPos1 = lngPos2 + 2
Next
Return
End Sub
Its only performing the string text coloring operation on the first row = C2. It should color all text strings between quotes from C2:C6.
It may be because of the carriage return spacing I put in the code. At any rate, I can't figure out where the problem is. It also colors
the rest in vbBlue.
Can anyone help to see where the problem in the code is?
Thanks very much for anyone's help.
cr