Different ways of generating same range object gives differentresults

P

paul.domaskis

I am using the code at http://www.vbaexpress.com/kb/archive.php/k-743.html
to change the color of some text in an Excel 2003 spreadsheet.

Here is how I am generating the range object specifier:

ActiveCell.Offset(0, 1) = "TopLine" & vbLf & "BottomLine"
ActiveCell.Offset(0, 1).Font.Color = vbBlack

'Call xlCellTextMgmt(Range("K20"), "TopLine", , , , , 3)
Call xlCellTextMgmt(ActiveCell(0, 1), "TopLine", , , , , 3)

When I submit Range("K20") to xlCellTextMgmt, nothing happens. When I
submit ActiveCell(0, 1) instead, all is fine. I know that they refer
to the same cell because the first two lines populate that cell.

Thanks for any debugging suggestions....Been banging at it for a while.
 
J

Joel

The only way I see there being a difference if there was merged cells. I
cell a1: and B1 were merged together accessing B1 would give an error while
Range("A1").offset(0,1) would give C1.
 
P

paul.domaskis

Actually, I found the problem. I supplied indices (0,1) to ActiveCell
rather than ActiveCell.Offset. Amazing what a new day can do.

Thanks!
 

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