Limit on Column Selection

H

Haarish

Hi All,

I have a requirement where I might need to replace the text in Cells
for particular columns. I have a form where I get the input from the
user asking them the fields they would want me to replace the text in.
I store the column numbers in a variant array. I then do an iteration
which is something like

Do While (intFieldCount <= UBound(vUpdFieldsCol))
strCol = Left(Cells(1, vUpdFieldsCol
(intFieldCount)).Address(False, False), 1 - (vUpdFieldsCol
(intFieldCount) > 26))
If (Len(strSelection) = 0) Then
strSelection = strSelection & strCol & "9:" &
strCol & intRngEnd
Else
strSelection = strSelection & "," & strCol &
"9:" & strCol & intRngEnd
End If
intFieldCount = intFieldCount + 1
Loop

But after the strSelection construction has been completed I do a
Sheet.Range(strSelection).select which fails and when I debug the
value of strSelection, I find the value has not been completely picked
up. I checked to see the limit of the datatype string and my values
are just a miniscule fraction of the 2 billion characters. Am I
missing something, can you guys let me know whats wrong with what I
have written?

Thanks and Regards,
Haarish.
 
J

Joel

I re-wrote the code and it doesn't look like it does what you are expecting

Do While (intFieldCount <= UBound(vUpdFieldsCol))

MyStr = Cells(1,
vUpdFieldsCol(intFieldCount)).Address(RowAbsolute:=False,
columnabsolute:=False)
if vUpdFieldsCol(intFieldCount) > 26 then

strCol = Left(MyStr, 0)
else
strcol = left(MyStr, 1)
end if

If (Len(strSelection) = 0) Then
strSelection = strSelection & strCol & "9:" & strCol & intRngEnd
Else
strSelection = strSelection & "," & strCol & "9:" & strCol &
intRngEnd
End If

intFieldCount = intFieldCount + 1
Loop
 

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

Top