ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formulas and colorindex don't work after opentext (https://www.excelbanter.com/excel-programming/332125-formulas-colorindex-dont-work-after-opentext.html)

Keith[_17_]

formulas and colorindex don't work after opentext
 
I am opening a text file with OpenText but when I do, and then try setting
the background color, the row color doesn't change. Yet when I set the
color from a different sub, executed AFTER the initial sub, the color is
set. Anyone experience weirdness like this before?

This is the opentext line:

Workbooks.OpenText Filename:=varFileName, DataType:=xlFixedWidth,
fieldinfo:=Array(Array(0, 1), Array(9, 2), Array(21, 3), Array(32, 1),
Array(40, 1), Array(48, 1), Array(54, 1), Array(65, 1), Array(74, 1),
Array(83, 1), Array(89, 1), Array(100, 1))

and the formula and color settings:

Cells(r, 1).EntireRow.Interior.ColorIndex = 5

yet these subs work - after the initial sub is finished - but not when
called from within the initial sub.

Sub a()
setrowcolor 5, 3
End Sub



Sub setrowcolor(rownum, rowcolor)
Cells(rownum, 1).EntireRow.Interior.ColorIndex = rowcolor
End Sub

Thanks,
Keith



Keith[_17_]

formulas and colorindex don't work after opentext
 
Please forgive my error. I found a logic error which prevented the code in
that area from being executed.

Sorry.


"Keith" wrote in message
...
I am opening a text file with OpenText but when I do, and then try setting
the background color, the row color doesn't change. Yet when I set the
color from a different sub, executed AFTER the initial sub, the color is
set. Anyone experience weirdness like this before?

This is the opentext line:

Workbooks.OpenText Filename:=varFileName, DataType:=xlFixedWidth,
fieldinfo:=Array(Array(0, 1), Array(9, 2), Array(21, 3), Array(32, 1),
Array(40, 1), Array(48, 1), Array(54, 1), Array(65, 1), Array(74, 1),
Array(83, 1), Array(89, 1), Array(100, 1))

and the formula and color settings:

Cells(r, 1).EntireRow.Interior.ColorIndex = 5

yet these subs work - after the initial sub is finished - but not when
called from within the initial sub.

Sub a()
setrowcolor 5, 3
End Sub



Sub setrowcolor(rownum, rowcolor)
Cells(rownum, 1).EntireRow.Interior.ColorIndex = rowcolor
End Sub

Thanks,
Keith





All times are GMT +1. The time now is 02:04 PM.

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