ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Limit on Column Selection (https://www.excelbanter.com/excel-programming/431780-limit-column-selection.html)

Haarish

Limit on Column Selection
 
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.

joel

Limit on Column Selection
 
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


"Haarish" wrote:

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.



All times are GMT +1. The time now is 05:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com