Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - select firsty 30 characters of a cell

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


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Excel VBA - select firsty 30 characters of a cell

Check out my response in your first post.

--
Regards,

Juan Pablo González

"ozcank " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel VBA - select firsty 30 characters of a cell


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)

"ozcank " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - select firsty 30 characters of a cell

Use the Left function:
strReadName = Left(.Cells(intRow, 2),31)


Pat

ozcank wrote in message ...
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


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert 5 characters in a cell to 6 characters by adding a zero Helenf Excel Discussion (Misc queries) 4 May 18th 09 04:43 PM
How do you select multiple characters in a drop down list to appe. Ross Noble Excel Worksheet Functions 2 August 11th 08 11:43 PM
copy select characters from specified cells. Ron Excel Worksheet Functions 3 October 9th 06 08:40 PM
select a string of characters Did Excel Worksheet Functions 7 August 17th 05 04:24 AM
select only certain characters from a cell. SS[_2_] Excel Programming 3 December 10th 03 06:43 PM


All times are GMT +1. The time now is 07:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"