Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Code works within VBE but not from Excel

I have code that populates a list of cells then applies formating depending
on the content. Like:

If APercent 0 And APercent < 100 Then
Worksheets("List").Range(Cells(tcnt + 4, 4), Cells(tcnt + 4,
8)).Font.ColorIndex = 10
End If

The code works fine when run from within the VB Editor. But if I run it
from Excel (menu or button) the cells are populated but the cells are not
formated. I have tested that the formatting code is being run.

Any ideas of what is going on here?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Code works within VBE but not from Excel

SC

Just a guess, but it may be because you have unqualified Cells methods.
Depending on where your code is the Cells will be method of the ActiveSheet,
not Worksheets("List")

With Worksheets("List")
.Range(.Cells(tcnt+4,4),.Cells(tcnt+4,8).font etc..
End With

Note the period before Cells. I think if this was the problem, then you
would get an error, but it's all I could see.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"SpaceCamel" wrote in message
...
I have code that populates a list of cells then applies formating

depending
on the content. Like:

If APercent 0 And APercent < 100 Then
Worksheets("List").Range(Cells(tcnt + 4, 4), Cells(tcnt + 4,
8)).Font.ColorIndex = 10
End If

The code works fine when run from within the VB Editor. But if I run it
from Excel (menu or button) the cells are populated but the cells are not
formated. I have tested that the formatting code is being run.

Any ideas of what is going on here?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Code works within VBE but not from Excel

OK, That did it! Thanks.

Now tell me why it worked from the VBE but didn't from from the App?

===================
"Dick Kusleika" wrote:

SC

Just a guess, but it may be because you have unqualified Cells methods.
Depending on where your code is the Cells will be method of the ActiveSheet,
not Worksheets("List")

With Worksheets("List")
.Range(.Cells(tcnt+4,4),.Cells(tcnt+4,8).font etc..
End With

Note the period before Cells. I think if this was the problem, then you
would get an error, but it's all I could see.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"SpaceCamel" wrote in message
...
I have code that populates a list of cells then applies formating

depending
on the content. Like:

If APercent 0 And APercent < 100 Then
Worksheets("List").Range(Cells(tcnt + 4, 4), Cells(tcnt + 4,
8)).Font.ColorIndex = 10
End If

The code works fine when run from within the VB Editor. But if I run it
from Excel (menu or button) the cells are populated but the cells are not
formated. I have tested that the formatting code is being run.

Any ideas of what is going on here?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Code works within VBE but not from Excel

Because while you were in the VBE, sheet "List" was the active sheet?

In article ,
"SpaceCamel" wrote:

Now tell me why it worked from the VBE but didn't from from the App?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB6 Excel 97 code no longer works if Win2K SP3/4 applied. Tim R[_3_] Excel Programming 5 October 10th 04 06:24 AM
Code works with Excel 2000 but not with Excel 2002 La Durande Excel Programming 0 September 17th 04 09:46 PM
Code works with Excel 2000 but not with Excel 2002 Tom Ogilvy Excel Programming 0 September 17th 04 09:21 PM
Code works with Excel 2000 but not with Excel 2002 La Durande Excel Programming 0 September 17th 04 08:49 PM
code works in excel 2002, but not in excel 2003 pyc Excel Programming 2 September 2nd 04 01:16 PM


All times are GMT +1. The time now is 01:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"