Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Opening or Looking for Another Workbook


Hello: This has two (2) questions:

The first and annoying question is: I have the following macro tha
was built to group items with a + symbol in front. It works grea
except that it is always looking for the original workbook it wa
created in. I opened the original workbook and copied then paste i
another workbook. If I move the original workbook the macro fails i
the file I pasted the macro. It probably is something relatively eas
that I am missing.

2nd: I added a macro that will collapse the groups after my workshee
is updated. It does not recognize the coding on the bottom.

Any help with both these problems will greatly be appreciated. Here i
my code:


Sub GroupData()

Dim wb As Workbook, ws As Worksheet
Dim cel As Range, GroupStart As Range, FirstCel As Boolean
Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
If ws.Name = "52_Weeks" Or ws.Name = "13_Weeks" Or ws.Name = "YTD
Then
ws.Activate
ws.Cells.ClearOutline
For Each cel In ws.Range("A1", ws.Range("A65535").End(xlUp).Offset(1
0))
If Left(cel, 1) = "+" And FirstCel = False Then
Set GroupStart = cel
FirstCel = True
End If
If Left(cel, 1) < "+" And FirstCel = True Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
If cel.Address = ws.Range("A65535").End(xlUp).Offset(1, 0) Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If


Next cel
End If
Next ws

Sheets("YTD").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("52_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("13_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select

End Sub



Again, thanks for your help.

Stev

--
Toolman04
-----------------------------------------------------------------------
Toolman045's Profile: http://www.excelforum.com/member.php...fo&userid=3532
View this thread: http://www.excelforum.com/showthread.php?threadid=55098

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro Opening or Looking for Another Workbook

Based on your explanation, I would suspect you have the macro assigned to a
button or other control. Go into that control and reasign the macro or
change the location of the macro it is looking for.

--
regards,
Tom Ogilvy


"Toolman045" wrote:


Hello: This has two (2) questions:

The first and annoying question is: I have the following macro that
was built to group items with a + symbol in front. It works great
except that it is always looking for the original workbook it was
created in. I opened the original workbook and copied then paste in
another workbook. If I move the original workbook the macro fails in
the file I pasted the macro. It probably is something relatively easy
that I am missing.

2nd: I added a macro that will collapse the groups after my worksheet
is updated. It does not recognize the coding on the bottom.

Any help with both these problems will greatly be appreciated. Here is
my code:


Sub GroupData()

Dim wb As Workbook, ws As Worksheet
Dim cel As Range, GroupStart As Range, FirstCel As Boolean
Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
If ws.Name = "52_Weeks" Or ws.Name = "13_Weeks" Or ws.Name = "YTD"
Then
ws.Activate
ws.Cells.ClearOutline
For Each cel In ws.Range("A1", ws.Range("A65535").End(xlUp).Offset(1,
0))
If Left(cel, 1) = "+" And FirstCel = False Then
Set GroupStart = cel
FirstCel = True
End If
If Left(cel, 1) < "+" And FirstCel = True Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
If cel.Address = ws.Range("A65535").End(xlUp).Offset(1, 0) Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If


Next cel
End If
Next ws

Sheets("YTD").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("52_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("13_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select

End Sub



Again, thanks for your help.

Steve


--
Toolman045
------------------------------------------------------------------------
Toolman045's Profile: http://www.excelforum.com/member.php...o&userid=35324
View this thread: http://www.excelforum.com/showthread...hreadid=550986


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro Opening or Looking for Another Workbook

maybe you have assigned to a button with a link

editlinkschange links

maybe you want to put in your personal.xls to be available everywhere?

--
Don Guillett
SalesAid Software

"Toolman045" wrote
in message ...

Hello: This has two (2) questions:

The first and annoying question is: I have the following macro that
was built to group items with a + symbol in front. It works great
except that it is always looking for the original workbook it was
created in. I opened the original workbook and copied then paste in
another workbook. If I move the original workbook the macro fails in
the file I pasted the macro. It probably is something relatively easy
that I am missing.

2nd: I added a macro that will collapse the groups after my worksheet
is updated. It does not recognize the coding on the bottom.

Any help with both these problems will greatly be appreciated. Here is
my code:


Sub GroupData()

Dim wb As Workbook, ws As Worksheet
Dim cel As Range, GroupStart As Range, FirstCel As Boolean
Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
If ws.Name = "52_Weeks" Or ws.Name = "13_Weeks" Or ws.Name = "YTD"
Then
ws.Activate
ws.Cells.ClearOutline
For Each cel In ws.Range("A1", ws.Range("A65535").End(xlUp).Offset(1,
0))
If Left(cel, 1) = "+" And FirstCel = False Then
Set GroupStart = cel
FirstCel = True
End If
If Left(cel, 1) < "+" And FirstCel = True Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If
If cel.Address = ws.Range("A65535").End(xlUp).Offset(1, 0) Then
ws.Range(GroupStart, cel.Offset(-1, 0)).Select
Selection.Rows.Group
FirstCel = False
End If


Next cel
End If
Next ws

Sheets("YTD").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("52_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select
Sheets("13_Weeks").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
Range("A1").Select

End Sub



Again, thanks for your help.

Steve


--
Toolman045
------------------------------------------------------------------------
Toolman045's Profile:
http://www.excelforum.com/member.php...o&userid=35324
View this thread: http://www.excelforum.com/showthread...hreadid=550986



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Opening or Looking for Another Workbook


Don & Tom: Both of you provided great feedback. However, I know I hav
not assigned a button to the code and where would I search for th
control?

I am totally lost when you indicate to place the Macro in my persona
xls so the code is avaiable everywhere.

I should tell you that someone else helped me create the code based o
what I needed to be accomplished in the workbook.

Any more help will be appreciated

--
Toolman04
-----------------------------------------------------------------------
Toolman045's Profile: http://www.excelforum.com/member.php...fo&userid=3532
View this thread: http://www.excelforum.com/showthread.php?threadid=55098

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro Opening or Looking for Another Workbook

there is nothing in your code to cause it to refer to the original workbook.
Set wb = ActiveWorkbook

is used at the top of the code and your references seem to build down from
that - so if the original workbook is not open, it should not be invovled.

How do you run this macro?

--
Regards,
Tom Ogilvy



"Toolman045" wrote:


Don & Tom: Both of you provided great feedback. However, I know I have
not assigned a button to the code and where would I search for the
control?

I am totally lost when you indicate to place the Macro in my personal
xls so the code is avaiable everywhere.

I should tell you that someone else helped me create the code based on
what I needed to be accomplished in the workbook.

Any more help will be appreciated.


--
Toolman045
------------------------------------------------------------------------
Toolman045's Profile: http://www.excelforum.com/member.php...o&userid=35324
View this thread: http://www.excelforum.com/showthread...hreadid=550986




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Opening or Looking for Another Workbook


Tom Wrote:

there is nothing in your code to cause it to refer to the original
workbook.
Set wb = ActiveWorkbook

is used at the top of the code and your references seem to build down
from
that - so if the original workbook is not open, it should not be
invovled.

How do you run this macro?

--
Regards,
Tom Ogilvy

Tom: I agree with you. However, if I do not have the original
workbook called Master Hierachy Report in the same directory of the
workbook I am working on, the macro says "Can't Find Master Hierarchy
Report" If it is in the same directory, the Macro opens the master
hierachhy Report to run the macro in the workbook I am working on.

I have an Add-in program in my Excel named XLerate. The add-in alllows
me to build ranges for Time, Product, geography and measures in a range.
After building the range, I have a tool in my macro that allows me to
run a macro after the update. All I have to do is point to the macro
that is in the current workbook I am working on (GroupData).

Now that I am writing this. The Groupdata macro name is the sub name
that is in the Master Heirachy workbook. Do you think it is open the
same macro with the same names in the same folder?

Tom thanks again for any help. Do we know why the macro does not close
or collaspe the groups?

Steve


--
Toolman045
------------------------------------------------------------------------
Toolman045's Profile: http://www.excelforum.com/member.php...o&userid=35324
View this thread: http://www.excelforum.com/showthread...hreadid=550986

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Opening or Looking for Another Workbook

I don't know anything about your addin, but it sounds like it has been set
up to run the macro from your old workbook (it contains the full path and so
forth to your old workbook). If you want to run a different macro, you
will need to figure out how to modify the setting in the addin (my guess).


--
Regards,
Tom Ogilvy

"Toolman045" wrote
in message ...

Tom Wrote:

there is nothing in your code to cause it to refer to the original
workbook.
Set wb = ActiveWorkbook

is used at the top of the code and your references seem to build down
from
that - so if the original workbook is not open, it should not be
invovled.

How do you run this macro?

--
Regards,
Tom Ogilvy

Tom: I agree with you. However, if I do not have the original
workbook called Master Hierachy Report in the same directory of the
workbook I am working on, the macro says "Can't Find Master Hierarchy
Report" If it is in the same directory, the Macro opens the master
hierachhy Report to run the macro in the workbook I am working on.

I have an Add-in program in my Excel named XLerate. The add-in alllows
me to build ranges for Time, Product, geography and measures in a range.
After building the range, I have a tool in my macro that allows me to
run a macro after the update. All I have to do is point to the macro
that is in the current workbook I am working on (GroupData).

Now that I am writing this. The Groupdata macro name is the sub name
that is in the Master Heirachy workbook. Do you think it is open the
same macro with the same names in the same folder?

Tom thanks again for any help. Do we know why the macro does not close
or collaspe the groups?

Steve


--
Toolman045
------------------------------------------------------------------------
Toolman045's Profile:

http://www.excelforum.com/member.php...o&userid=35324
View this thread: http://www.excelforum.com/showthread...hreadid=550986



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
Opening a Workbook with a Macro Eli[_4_] Excel Discussion (Misc queries) 4 October 3rd 08 12:13 AM
Enable macro on opening workbook ASU Excel Discussion (Misc queries) 5 July 3rd 06 05:40 PM
Programming a macro to run on opening a workbook mike Excel Programming 3 October 27th 05 01:07 PM
Run macro when opening workbook nsv Excel Discussion (Misc queries) 4 September 6th 05 12:19 PM
How to make macro available to all workbook w/o opening VBA crapit Excel Programming 3 May 19th 05 05:27 PM


All times are GMT +1. The time now is 01:05 PM.

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"