Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Workbook_Open Question

gm

Unless EnableEvents is False or your Workbook_Open sub is the wrong place,
then I think it should work. Put a MsgBox in the workbook open and see if
it's even executed. If not, I'll bet it's in the wrong module. Make sure
it's in the ThisWorkbok module.

Generally, you don't need to Select objects in order to work with them, and
it's inefficient. You might consider changing that sub to

Dim i As Long

With ActiveSheet
For i = 2 to .Rows.Count Step 2
If IsEmpty(.Cells(i,1)) Then
Exit For
Else
.Cells(i,1).EntireRow.Interior.ColorIndex = 15
End If
Next i
End With

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


wrote:
I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default Workbook_Open Question

On Sat, 14 Aug 2004 22:28:56 -0600, JE McGimpsey
wrote:

RBUnless you don't have the Workbook_Open() code in the ThisWorkbook
RBmodule, it should work fine.
RB
RBHowever, instead of running a macro every time, why not select the
RBentire sheet and use the technique found he
RB
RB http://cpearson.com/excel/banding.htm

That's an extremely interesting method and works very well for
predefined cells. However i've just tried capturing the conditional
formatting key strokes in a macro and other than the first 'select',
nothing else appears.

I'd like to be able to apply this conditional formatting to new rows
introduced by some other VBA code. I could I suppose hold this
formatting in cells in a 'spare' row and copy the formatting each time
a row is introduced, but I'd like to know how to apply it directly
with code.

Any ideas?

Many thanks,

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Workbook_Open Question

One way:

Public Sub ApplyCF()
With Range("A1:A" & Range("A" & Rows.Count).End( _
xlUp).Row).EntireRow.FormatConditions
.Delete
With .Add(Type:=xlExpression, _
Formula1:="=MOD(ROW(),2)=0")
.Interior.ColorIndex = 35
End With
End With
End Sub

Adjust your row definition as necessary.


In article ,
Richard Buttrey wrote:

That's an extremely interesting method and works very well for
predefined cells. However i've just tried capturing the conditional
formatting key strokes in a macro and other than the first 'select',
nothing else appears.

I'd like to be able to apply this conditional formatting to new rows
introduced by some other VBA code. I could I suppose hold this
formatting in cells in a 'spare' row and copy the formatting each time
a row is introduced, but I'd like to know how to apply it directly
with code.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Workbook_Open Question

Using Pearson's formula, the code is:

With Range("D1:D30")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW()-1,3*2)+1<=3"
.FormatConditions(1).Interior.ColorIndex = 35
End With

Mike F
"Richard Buttrey" wrote in
message ...
On Sat, 14 Aug 2004 22:28:56 -0600, JE McGimpsey
wrote:

RBUnless you don't have the Workbook_Open() code in the ThisWorkbook
RBmodule, it should work fine.
RB
RBHowever, instead of running a macro every time, why not select the
RBentire sheet and use the technique found he
RB
RB http://cpearson.com/excel/banding.htm

That's an extremely interesting method and works very well for
predefined cells. However i've just tried capturing the conditional
formatting key strokes in a macro and other than the first 'select',
nothing else appears.

I'd like to be able to apply this conditional formatting to new rows
introduced by some other VBA code. I could I suppose hold this
formatting in cells in a 'spare' row and copy the formatting each time
a row is introduced, but I'd like to know how to apply it directly
with code.

Any ideas?

Many thanks,

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

The Workbook_Open() code is in the ThisWorkbook module, and it still
doesn't work. Thanks for the suggestion, but I prefer running it on
open so that each time the worksheet opens it corrects for any changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article , wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

Thanks for the reply. I added the msgbox as you suggest, so now workbook open
looks like:
----------------------------------------------------------------
Private Sub Workbook_Open()
MsgBox ("Workbook open in progress")
ShadeEveryOtherRow
----------------------------------------------------------------
The message box happens, the other code still does not execute. I am assuming
that since the message box is working, then the EnableEvents you mention is not
False.

So can anyone else come up with another reason why this code will not execute
on workbook open?

thanks
gm

Dick Kusleika wrote:

gm

Unless EnableEvents is False or your Workbook_Open sub is the wrong place,
then I think it should work. Put a MsgBox in the workbook open and see if
it's even executed. If not, I'll bet it's in the wrong module. Make sure
it's in the ThisWorkbok module.

Generally, you don't need to Select objects in order to work with them, and
it's inefficient. You might consider changing that sub to

Dim i As Long

With ActiveSheet
For i = 2 to .Rows.Count Step 2
If IsEmpty(.Cells(i,1)) Then
Exit For
Else
.Cells(i,1).EntireRow.Interior.ColorIndex = 15
End If
Next i
End With

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

wrote:
I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Workbook_Open Question

How do you open the workbook with the workbook_open event? Do you open it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message ...
The Workbook_Open() code is in the ThisWorkbook module, and it still
doesn't work. Thanks for the suggestion, but I prefer running it on
open so that each time the worksheet opens it corrects for any changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article , wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm







  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

I believe you are on to something Tom. I do open the file with a macro, and
if I open it manually, the worksheet_open event runs correctly. So now what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you open it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message ...
The Workbook_Open() code is in the ThisWorkbook module, and it still
doesn't work. Thanks for the suggestion, but I prefer running it on
open so that each time the worksheet opens it corrects for any changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article , wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm











  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Workbook_Open Question

Is the correct sheet the active sheet? Or, is A2 not empty?

Perhaps a blank sheet is the activesheet and thus your code executes, but
does nothing.

Put the message box in the ShadeEveryOtherRow code at the top as the first
executable instruction.

--
Regards,
Tom Ogilvy

wrote in message ...
Thanks for the reply. I added the msgbox as you suggest, so now workbook

open
looks like:
----------------------------------------------------------------
Private Sub Workbook_Open()
MsgBox ("Workbook open in progress")
ShadeEveryOtherRow
----------------------------------------------------------------
The message box happens, the other code still does not execute. I am

assuming
that since the message box is working, then the EnableEvents you mention

is not
False.

So can anyone else come up with another reason why this code will not

execute
on workbook open?

thanks
gm

Dick Kusleika wrote:

gm

Unless EnableEvents is False or your Workbook_Open sub is the wrong

place,
then I think it should work. Put a MsgBox in the workbook open and see

if
it's even executed. If not, I'll bet it's in the wrong module. Make

sure
it's in the ThisWorkbok module.

Generally, you don't need to Select objects in order to work with them,

and
it's inefficient. You might consider changing that sub to

Dim i As Long

With ActiveSheet
For i = 2 to .Rows.Count Step 2
If IsEmpty(.Cells(i,1)) Then
Exit For
Else
.Cells(i,1).EntireRow.Interior.ColorIndex = 15
End If
Next i
End With

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

wrote:
I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm







  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Workbook_Open Question

If you open it using a macro started with a shortcut key combination that
includes the Shift Key, then you need to use one that does not use the shift
key. the shift key seems to disable macros (similar to when you open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message ...
I believe you are on to something Tom. I do open the file with a macro,

and
if I open it manually, the worksheet_open event runs correctly. So now

what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you open

it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message ...
The Workbook_Open() code is in the ThisWorkbook module, and it still
doesn't work. Thanks for the suggestion, but I prefer running it on
open so that each time the worksheet opens it corrects for any changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article , wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm










  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code as you
suggested, and that statement IS being executed, but nothing else. I tried
adding some code to the top of ShadeEveryOtherRow that would guarantee the
process starts at the A2 cell in the first sheet with these lined at the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next two lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination that
includes the Shift Key, then you need to use one that does not use the shift
key. the shift key seems to disable macros (similar to when you open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message ...
I believe you are on to something Tom. I do open the file with a macro,

and
if I open it manually, the worksheet_open event runs correctly. So now

what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you open

it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message ...
The Workbook_Open() code is in the ThisWorkbook module, and it still
doesn't work. Thanks for the suggestion, but I prefer running it on
open so that each time the worksheet opens it corrects for any changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article , wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm












  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Workbook_Open Question

gm

Instead of a MsgBox, put Stop. That will break the code and you can use F8
to go through it line by line. If, when you get to the If statement, it
passes it by, you'll know that A2 is really empty.

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

wrote in message ...
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code as

you
suggested, and that statement IS being executed, but nothing else. I

tried
adding some code to the top of ShadeEveryOtherRow that would guarantee the
process starts at the A2 cell in the first sheet with these lined at the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next two

lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination

that
includes the Shift Key, then you need to use one that does not use the

shift
key. the shift key seems to disable macros (similar to when you open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message ...
I believe you are on to something Tom. I do open the file with a

macro,
and
if I open it manually, the worksheet_open event runs correctly. So

now
what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you

open
it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message

...
The Workbook_Open() code is in the ThisWorkbook module, and it

still
doesn't work. Thanks for the suggestion, but I prefer running it

on
open so that each time the worksheet opens it corrects for any

changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the

ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select

the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,

wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8

----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub

----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,


----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub

----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm














  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbook_Open Question

Just a suggestion:
If you open your file using a macro, put in that macro:
Workbooks.Open "C:\YourFile.xls"
ActiveWorkbook.RunAutoMacros xlAutoOpen

and, in your file call 'ShadeEveryOtherRow' from
Auto_Open() instead Workbook_Open()

--
pozdrav!
Berislav


wrote in message
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code
as you suggested, and that statement IS being executed, but nothing
else. I tried adding some code to the top of ShadeEveryOtherRow that
would guarantee the process starts at the A2 cell in the first sheet
with these lined at the beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next
two lines only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination
that includes the Shift Key, then you need to use one that does not
use the shift key. the shift key seems to disable macros (similar
to when you open a workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message
...
I believe you are on to something Tom. I do open the file with a
macro, and if I open it manually, the worksheet_open event runs
correctly. So now what? gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you
open it with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message
...
The Workbook_Open() code is in the ThisWorkbook module, and it
still doesn't work. Thanks for the suggestion, but I prefer
running it on open so that each time the worksheet opens it
corrects for any changes made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the
ThisWorkbook module, it should work fine.

However, instead of running a macro every time, why not select
the entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,
wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm











  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

I did as you suggested, it doesn't appear to show anything though. Cell A2 is
not empty (it contains 20040415A), but the macro still refuses to execute on
open from a macro!
thanks for the input
gm

Dick Kusleika wrote:

gm

Instead of a MsgBox, put Stop. That will break the code and you can use F8
to go through it line by line. If, when you get to the If statement, it
passes it by, you'll know that A2 is really empty.

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

wrote in message ...
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code as

you
suggested, and that statement IS being executed, but nothing else. I

tried
adding some code to the top of ShadeEveryOtherRow that would guarantee the
process starts at the A2 cell in the first sheet with these lined at the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next two

lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination

that
includes the Shift Key, then you need to use one that does not use the

shift
key. the shift key seems to disable macros (similar to when you open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message ...
I believe you are on to something Tom. I do open the file with a

macro,
and
if I open it manually, the worksheet_open event runs correctly. So

now
what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you

open
it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message

...
The Workbook_Open() code is in the ThisWorkbook module, and it

still
doesn't work. Thanks for the suggestion, but I prefer running it

on
open so that each time the worksheet opens it corrects for any

changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the

ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not select

the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,

wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8

----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub

----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,


----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub

----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm
















  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

Tried it, no change! Thanks anyway. Sooner or later some excel vba guru
will chime in with the explaination.
gm


b&s wrote:

Just a suggestion:
If you open your file using a macro, put in that macro:
Workbooks.Open "C:\YourFile.xls"
ActiveWorkbook.RunAutoMacros xlAutoOpen

and, in your file call 'ShadeEveryOtherRow' from
Auto_Open() instead Workbook_Open()

--
pozdrav!
Berislav

wrote in message
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code
as you suggested, and that statement IS being executed, but nothing
else. I tried adding some code to the top of ShadeEveryOtherRow that
would guarantee the process starts at the A2 cell in the first sheet
with these lined at the beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next
two lines only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination
that includes the Shift Key, then you need to use one that does not
use the shift key. the shift key seems to disable macros (similar
to when you open a workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message
...
I believe you are on to something Tom. I do open the file with a
macro, and if I open it manually, the worksheet_open event runs
correctly. So now what? gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do you
open it with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message
...
The Workbook_Open() code is in the ThisWorkbook module, and it
still doesn't work. Thanks for the suggestion, but I prefer
running it on open so that each time the worksheet opens it
corrects for any changes made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the
ThisWorkbook module, it should work fine.

However, instead of running a macro every time, why not select
the entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,
wrote:

I have the following sub that will shade every other row in
a spreadsheet. It works fine if I run it manually via
alt-F8
----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub
----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,

----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub
----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm





  #18   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Workbook_Open Question

gm

If you like, you can email a copy of the workbook to me.

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

wrote in message ...
I did as you suggested, it doesn't appear to show anything though. Cell A2

is
not empty (it contains 20040415A), but the macro still refuses to execute

on
open from a macro!
thanks for the input
gm

Dick Kusleika wrote:

gm

Instead of a MsgBox, put Stop. That will break the code and you can use

F8
to go through it line by line. If, when you get to the If statement, it
passes it by, you'll know that A2 is really empty.

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

wrote in message ...
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code

as
you
suggested, and that statement IS being executed, but nothing else. I

tried
adding some code to the top of ShadeEveryOtherRow that would guarantee

the
process starts at the A2 cell in the first sheet with these lined at

the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next

two
lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination

that
includes the Shift Key, then you need to use one that does not use

the
shift
key. the shift key seems to disable macros (similar to when you

open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message

...
I believe you are on to something Tom. I do open the file with a

macro,
and
if I open it manually, the worksheet_open event runs correctly.

So
now
what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do

you
open
it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message

...
The Workbook_Open() code is in the ThisWorkbook module, and it

still
doesn't work. Thanks for the suggestion, but I prefer running

it
on
open so that each time the worksheet opens it corrects for any

changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the

ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not

select
the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,

wrote:

I have the following sub that will shade every other row

in
a spreadsheet. It works fine if I run it manually via
alt-F8

----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub

----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,


----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub

----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm


















  #19   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

Thanks, I will use the email link from your blog site.

Dick Kusleika wrote:

gm

If you like, you can email a copy of the workbook to me.

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

wrote in message ...
I did as you suggested, it doesn't appear to show anything though. Cell A2

is
not empty (it contains 20040415A), but the macro still refuses to execute

on
open from a macro!
thanks for the input
gm

Dick Kusleika wrote:

gm

Instead of a MsgBox, put Stop. That will break the code and you can use

F8
to go through it line by line. If, when you get to the If statement, it
passes it by, you'll know that A2 is really empty.

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

wrote in message ...
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow code

as
you
suggested, and that statement IS being executed, but nothing else. I
tried
adding some code to the top of ShadeEveryOtherRow that would guarantee

the
process starts at the A2 cell in the first sheet with these lined at

the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the next

two
lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key combination
that
includes the Shift Key, then you need to use one that does not use

the
shift
key. the shift key seems to disable macros (similar to when you

open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message

...
I believe you are on to something Tom. I do open the file with a
macro,
and
if I open it manually, the worksheet_open event runs correctly.

So
now
what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event? Do

you
open
it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message
...
The Workbook_Open() code is in the ThisWorkbook module, and it
still
doesn't work. Thanks for the suggestion, but I prefer running

it
on
open so that each time the worksheet opens it corrects for any
changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the
ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not

select
the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,
wrote:

I have the following sub that will shade every other row

in
a spreadsheet. It works fine if I run it manually via
alt-F8

----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub

----------------------------------------------------------------

But if I try to have it run at open, it does nothing. I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,


----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub

----------------------------------------------------------------

and that doesn't work either. What the heck is going on
here!?

Thanks,
gm




















  #20   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Workbook_Open Question

gm

It worked without issue for me. I created this sub to open the workbook

Sub OpenRebates()

Workbooks.Open "C:\Dick\Ng\08Aug\Rebates.xls"

End Sub

Assigned that to a commandbar button and it all worked fine using XL2000 on
Win98SE (although I don't think the version matters in this case.)

The subs that you have in the ThisWorkbook module should be in standard
modules. Only use the ThisWorkbook module for event procedures (or other
class specific procedures). That's not the problem because it worked for me
as you sent it without modification, but you should move them anyway.

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


wrote in message ...
Thanks, I will use the email link from your blog site.

Dick Kusleika wrote:

gm

If you like, you can email a copy of the workbook to me.

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

wrote in message ...
I did as you suggested, it doesn't appear to show anything though.

Cell A2
is
not empty (it contains 20040415A), but the macro still refuses to

execute
on
open from a macro!
thanks for the input
gm

Dick Kusleika wrote:

gm

Instead of a MsgBox, put Stop. That will break the code and you can

use
F8
to go through it line by line. If, when you get to the If

statement, it
passes it by, you'll know that A2 is really empty.

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

wrote in message

...
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow

code
as
you
suggested, and that statement IS being executed, but nothing else.

I
tried
adding some code to the top of ShadeEveryOtherRow that would

guarantee
the
process starts at the A2 cell in the first sheet with these lined

at
the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the

next
two
lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key

combination
that
includes the Shift Key, then you need to use one that does not

use
the
shift
key. the shift key seems to disable macros (similar to when you

open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message

...
I believe you are on to something Tom. I do open the file

with a
macro,
and
if I open it manually, the worksheet_open event runs

correctly.
So
now
what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event?

Do
you
open
it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message
...
The Workbook_Open() code is in the ThisWorkbook module,

and it
still
doesn't work. Thanks for the suggestion, but I prefer

running
it
on
open so that each time the worksheet opens it corrects for

any
changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the
ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not

select
the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,


wrote:

I have the following sub that will shade every other

row
in
a spreadsheet. It works fine if I run it manually via
alt-F8

----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub

----------------------------------------------------------------

But if I try to have it run at open, it does nothing.

I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,


----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub

----------------------------------------------------------------

and that doesn't work either. What the heck is going

on
here!?

Thanks,
gm
























  #21   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Workbook_Open Question

Where did you place the OpenRebates sub?
gm

Dick Kusleika wrote:

gm

It worked without issue for me. I created this sub to open the workbook

Sub OpenRebates()

Workbooks.Open "C:\Dick\Ng\08Aug\Rebates.xls"

End Sub

Assigned that to a commandbar button and it all worked fine using XL2000 on
Win98SE (although I don't think the version matters in this case.)

The subs that you have in the ThisWorkbook module should be in standard
modules. Only use the ThisWorkbook module for event procedures (or other
class specific procedures). That's not the problem because it worked for me
as you sent it without modification, but you should move them anyway.

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

wrote in message ...
Thanks, I will use the email link from your blog site.

Dick Kusleika wrote:

gm

If you like, you can email a copy of the workbook to me.

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

wrote in message ...
I did as you suggested, it doesn't appear to show anything though.

Cell A2
is
not empty (it contains 20040415A), but the macro still refuses to

execute
on
open from a macro!
thanks for the input
gm

Dick Kusleika wrote:

gm

Instead of a MsgBox, put Stop. That will break the code and you can

use
F8
to go through it line by line. If, when you get to the If

statement, it
passes it by, you'll know that A2 is really empty.

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

wrote in message

...
The macro is opened via a button, no shift key....

I did move the message box to the top of the ShadeEveryOtherRow

code
as
you
suggested, and that statement IS being executed, but nothing else.

I
tried
adding some code to the top of ShadeEveryOtherRow that would

guarantee
the
process starts at the A2 cell in the first sheet with these lined

at
the
beginning:
----------------------------------------------------------------
Sub ShadeEveryOtherRow()
MsgBox ("ShadeEveryOtherRow open in progress")
Worksheets("To Be Recieved").Activate
Range("a2").Select
----------------------------------------------------------------

This has the same effect, the msgbox works either way, but the

next
two
lines
only work if the workbook is opened manually! What a pain!

So the gremlin is still at large.
gm

Tom Ogilvy wrote:

If you open it using a macro started with a shortcut key

combination
that
includes the Shift Key, then you need to use one that does not

use
the
shift
key. the shift key seems to disable macros (similar to when you
open a
workbook manually and hold down the shift key).

--
Regards,
Tom Ogilvy

wrote in message
...
I believe you are on to something Tom. I do open the file

with a
macro,
and
if I open it manually, the worksheet_open event runs

correctly.
So
now
what?
gm

Tom Ogilvy wrote:

How do you open the workbook with the workbook_open event?

Do
you
open
it
with a macro. Does the macro run if you open it manually?

--
Regards,
Tom Ogilvy

wrote in message
...
The Workbook_Open() code is in the ThisWorkbook module,

and it
still
doesn't work. Thanks for the suggestion, but I prefer

running
it
on
open so that each time the worksheet opens it corrects for

any
changes
made in the last edits.
Guy

JE McGimpsey wrote:

Unless you don't have the Workbook_Open() code in the
ThisWorkbook
module, it should work fine.

However, instead of running a macro every time, why not
select
the
entire sheet and use the technique found he

http://cpearson.com/excel/banding.htm

In article ,


wrote:

I have the following sub that will shade every other

row
in
a spreadsheet. It works fine if I run it manually via
alt-F8

----------------------------------------------------------------

Sub ShadeEveryOtherRow()

Range("A2").EntireRow.Select
Do While ActiveCell.Value < ""
Selection.Interior.ColorIndex = 15
ActiveCell.Offset(2, 0).EntireRow.Select
Loop
End Sub

----------------------------------------------------------------

But if I try to have it run at open, it does nothing.

I
have tried placing the code directly in workbook_open,
nothing happens. I have tried calling the sub in
workbook_open,


----------------------------------------------------------------

Private Sub Workbook_Open()
ShadeEveryOtherRow
End Sub

----------------------------------------------------------------

and that doesn't work either. What the heck is going

on
here!?

Thanks,
gm
























  #22   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Workbook_Open Question


wrote in message ...
Where did you place the OpenRebates sub?
gm


In a standard module in Personal.xls.

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


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
Workbook_Open () Bill Martin Excel Discussion (Misc queries) 12 December 20th 05 05:37 PM
Workbook_Open() not running Udo Fingerhut Excel Programming 2 July 30th 04 12:46 PM
Workbook_Open Eric Marple Excel Programming 3 May 10th 04 01:24 AM
Help with Workbook_Open Ruan[_3_] Excel Programming 7 April 28th 04 07:52 AM
Workbook_Open event and combobox state storage question jw Excel Programming 0 October 23rd 03 12:44 AM


All times are GMT +1. The time now is 06:18 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"