Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel macro - personal folder

I have created an excel macro and stored it in my personal.xlsm
workbook. I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel macro - personal folder

Hi Doogie

Change every thisworkbook in the code to activeworkbook

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Doogie" wrote in message ...
I have created an excel macro and stored it in my personal.xlsm
workbook. I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel macro - personal folder

When I have this kind of thing, I'll write the code to use the activesheet.

Any chance your code is specific in what sheet it uses?

You may want to post your code if this doesn't help.

Doogie wrote:

I have created an excel macro and stored it in my personal.xlsm
workbook. I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel macro - personal folder

On Jul 30, 1:58*pm, Dave Peterson wrote:
When I have this kind of thing, I'll write the code to use the activesheet.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel macro - personal folder

On Jul 30, 2:07*pm, Doogie wrote:
On Jul 30, 1:58*pm, Dave Peterson wrote:





When I have this kind of thing, I'll write the code to use the activesheet.


Any chance your code is specific in what sheet it uses?


You may want to post your code if this doesn't help.


Doogie wrote:


I have created an excel macro and stored it in my personal.xlsm
workbook. *I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. *How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?


--


Dave Peterson


Here's my code. *I don't have any place that I can see a thisWorkbook
from the other person's post so couldn't make those changes. (there
are more than 2 cases in my case statement, but I only put two here
for demonstrative purposes).

Sub changeTabNames()
* * Dim worksheetValue As String
* * Dim tabName As String
* * Dim worksheet

* * For Each worksheet In Worksheets
* * * * worksheetValue = Left(worksheet.Range("A6"), 2)

* * * * Select Case worksheetValue
* * * * * * Case "4D"
* * * * * * * * tabName = "4D-BALID"
* * * * * * Case "4I"
* * * * * * * * tabName = "4I-HNCUT"
* * * * End Select

* * * * worksheet.Name = tabName
* * Next

End Sub- Hide quoted text -

- Show quoted text -


I figured it out. I had to go one step up and check the
workbook...the only thing, I'm hardcoding a look for the
"personal.xlsm" file, which if there was a better way to do that I'd
like to.

Sub changeTabNames()
Dim worksheetValue As String
Dim tabName As String
Dim worksheet
Dim workbook

For Each workbook In Workbooks
If (workbook.Name < "personal.xlsm") Then
For Each worksheet In workbook.Worksheets
worksheetValue = Left(worksheet.Range("A6"), 2)

Select Case worksheetValue
Case "4D"
tabName = "4D-BALID"
Case "4I"
tabName = "4I-HNCUT"
End Select
Next
End If
Next

End Sub


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Excel macro - personal folder

This post seems to be related to my issue, but I cannot seem to fix it based
on info in this post.
My I get help with my Macro in Personal.xlsb?
This code works fine on the Workbook I originally created it in, but now I
find it so useful that I want it always available. I re-number worksheets in
the active workbook using the following, but it only re-numbers the
worksheets in Personal.xlsb when run from any other workbook:

Sub NumberWorksheets()
'Purpose is to pre-pend each worksheet name with number for easy reference.
'Replaces with numbers, starting with 1 at leftmost worksheet.

Dim iCtr As Long
Dim iPos As Long

For iCtr = 1 To Worksheets.Count
On Error Resume Next
With Worksheets(iCtr)
iPos = InStr(1, .Name, ".")
If iPos 0 Then
..Name = iCtr & "." & Right(.Name, Len(.Name) - iPos)
Else
..Name = iCtr & "." & .Name
End If
If Err.Number < 0 Then
MsgBox "Trouble with " & Worksheets(iCtr).Name
Err.Clear
End If
End With
Next iCtr

End Sub

"Ron de Bruin" wrote:

Hi Doogie

Change every thisworkbook in the code to activeworkbook

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Doogie" wrote in message ...
I have created an excel macro and stored it in my personal.xlsm
workbook. I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel macro - personal folder

Try it like this

Sub NumberWorksheets_2()
'Purpose is to pre-pend each worksheet name with number for easy reference.
'Replaces with numbers, starting with 1 at leftmost worksheet.

Dim iCtr As Long
Dim iPos As Long

For iCtr = 1 To ActiveWorkbook.Worksheets.Count
On Error Resume Next
With ActiveWorkbook.Worksheets(iCtr)
iPos = InStr(1, .Name, ".")
If iPos 0 Then
.Name = iCtr & "." & Right(.Name, Len(.Name) - iPos)
Else
.Name = iCtr & "." & .Name
End If
If Err.Number < 0 Then
MsgBox "Trouble with " & ActiveWorkbook.Worksheets(iCtr).Name
Err.Clear
End If
End With
Next iCtr

End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"KIM W" wrote in message ...
This post seems to be related to my issue, but I cannot seem to fix it based
on info in this post.
My I get help with my Macro in Personal.xlsb?
This code works fine on the Workbook I originally created it in, but now I
find it so useful that I want it always available. I re-number worksheets in
the active workbook using the following, but it only re-numbers the
worksheets in Personal.xlsb when run from any other workbook:

Sub NumberWorksheets()
'Purpose is to pre-pend each worksheet name with number for easy reference.
'Replaces with numbers, starting with 1 at leftmost worksheet.

Dim iCtr As Long
Dim iPos As Long

For iCtr = 1 To Worksheets.Count
On Error Resume Next
With Worksheets(iCtr)
iPos = InStr(1, .Name, ".")
If iPos 0 Then
.Name = iCtr & "." & Right(.Name, Len(.Name) - iPos)
Else
.Name = iCtr & "." & .Name
End If
If Err.Number < 0 Then
MsgBox "Trouble with " & Worksheets(iCtr).Name
Err.Clear
End If
End With
Next iCtr

End Sub

"Ron de Bruin" wrote:

Hi Doogie

Change every thisworkbook in the code to activeworkbook

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Doogie" wrote in message ...
I have created an excel macro and stored it in my personal.xlsm
workbook. I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Excel macro - personal folder

That was all it took!
:)

"Ron de Bruin" wrote:

Try it like this

Sub NumberWorksheets_2()
'Purpose is to pre-pend each worksheet name with number for easy reference.
'Replaces with numbers, starting with 1 at leftmost worksheet.

Dim iCtr As Long
Dim iPos As Long

For iCtr = 1 To ActiveWorkbook.Worksheets.Count
On Error Resume Next
With ActiveWorkbook.Worksheets(iCtr)
iPos = InStr(1, .Name, ".")
If iPos 0 Then
.Name = iCtr & "." & Right(.Name, Len(.Name) - iPos)
Else
.Name = iCtr & "." & .Name
End If
If Err.Number < 0 Then
MsgBox "Trouble with " & ActiveWorkbook.Worksheets(iCtr).Name
Err.Clear
End If
End With
Next iCtr

End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"KIM W" wrote in message ...
This post seems to be related to my issue, but I cannot seem to fix it based
on info in this post.
My I get help with my Macro in Personal.xlsb?
This code works fine on the Workbook I originally created it in, but now I
find it so useful that I want it always available. I re-number worksheets in
the active workbook using the following, but it only re-numbers the
worksheets in Personal.xlsb when run from any other workbook:

Sub NumberWorksheets()
'Purpose is to pre-pend each worksheet name with number for easy reference.
'Replaces with numbers, starting with 1 at leftmost worksheet.

Dim iCtr As Long
Dim iPos As Long

For iCtr = 1 To Worksheets.Count
On Error Resume Next
With Worksheets(iCtr)
iPos = InStr(1, .Name, ".")
If iPos 0 Then
.Name = iCtr & "." & Right(.Name, Len(.Name) - iPos)
Else
.Name = iCtr & "." & .Name
End If
If Err.Number < 0 Then
MsgBox "Trouble with " & Worksheets(iCtr).Name
Err.Clear
End If
End With
Next iCtr

End Sub

"Ron de Bruin" wrote:

Hi Doogie

Change every thisworkbook in the code to activeworkbook

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Doogie" wrote in message ...
I have created an excel macro and stored it in my personal.xlsm
workbook. I can access it from other workbooks just fine, but when I
execute it, it always executes the functionality against
personal.xlsm. How do I get it to ignore personal.xlsm and execute
against the other workbook I have open?


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
From Outlook to Excel Personal Folder Roy Hobbs Excel Worksheet Functions 0 October 10th 10 04:33 AM
Personal Macro Workbook in startup folder missing Susan Rochon Excel Discussion (Misc queries) 3 September 17th 09 02:44 AM
how do I create a personal folder Billy[_6_] Excel Programming 4 October 18th 07 05:29 PM
Personal.xls macro folder stopped working [email protected][_2_] Excel Programming 1 October 3rd 06 11:27 PM


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

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

About Us

"It's about Microsoft Excel"