Excel VBA - select firsty 30 characters of a cell

O

ozcank

Hi all,

I have the following code, which selects the name of a cell:

Private Sub getNames()
Dim intRow As Integer, wsMain As Worksheet
Dim strReadName As String

Set wsMain = ActiveWorkbook.Worksheets("ufioverdue")
intIdx = 0
intRow = 2
With wsMain
Do
strReadName = .Cells(intRow, 2)
strNames(intIdx) = strReadName

Do
intRow = intRow + 1
Loop Until strReadName <> .Cells(intRow, 2)

intIdx = intIdx + 1

Loop While .Cells(intRow, 2) <> ""
End With
intIdx = intIdx - 1

End Sub

What would I have to alter so that it would only select the first 31
characters of a cell? Any ideas?

Cheers
 
B

Bob Phillips

strReadName = Left(.Cells(intRow, 2),31)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top