Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
convert 5 characters in a cell to 6 characters by adding a zero | Excel Discussion (Misc queries) | |||
How do you select multiple characters in a drop down list to appe. | Excel Worksheet Functions | |||
copy select characters from specified cells. | Excel Worksheet Functions | |||
select a string of characters | Excel Worksheet Functions | |||
select only certain characters from a cell. | Excel Programming |