PC Review


Reply
Thread Tools Rate Thread

Different ways of generating same range object gives differentresults

 
 
paul.domaskis@gmail.com
Guest
Posts: n/a
 
      2nd Jun 2009
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.
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      3rd Jun 2009
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.

"(E-Mail Removed)" wrote:

> 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.
>

 
Reply With Quote
 
paul.domaskis@gmail.com
Guest
Posts: n/a
 
      3rd Jun 2009
Actually, I found the problem. I supplied indices (0,1) to ActiveCell
rather than ActiveCell.Offset. Amazing what a new day can do.

Thanks!

On Jun 2, 9:02*pm, Joel <J...@discussions.microsoft.com> wrote:
> 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.
>
> > I am using the code athttp://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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Uncommon ways of object access Peter Duniho Microsoft C# .NET 5 15th Nov 2007 06:02 PM
different ways to copy a range? botha822 Microsoft Excel Programming 6 8th Aug 2006 12:06 AM
Alternative Ways to Spellcheck a Range Jay Microsoft Excel Programming 4 17th May 2006 09:43 PM
Difference between ways of Object creation =?Utf-8?B?VG9t?= Microsoft Dot NET Framework 2 31st Oct 2005 06:19 AM
Instantiate an object in two ways??? J-T Microsoft ASP .NET 7 26th May 2005 05:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:07 PM.