Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Nev Nev is offline
external usenet poster
 
Posts: 20
Default Macro worts in workbook but not from Personal.xls

Hi there

With help from community I have a great macro. Trouble is that this section
will run in its own workbook but not when its in Personal.xls

Sub Copy_to_new_Workbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long

Macro then runs fine until after the option to save from here on

Application.Dialogs(xlDialogSaveAs).Show

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Change the file name (2*) and the path/file name to your file
If bIsBookOpen_RB("Master Copy.xls") Then
Set DestWB = Workbooks("Master Copy.xls")
Else
Set DestWB = Workbooks.Open("c:\block management\Master Copy.xls")
End If

'Change the Source Sheet and range
Set SourceRange = ThisWorkbook.Sheets("addresses").Range("b1:t500")
'Change the sheet name of the database workbook
Set DestSh = DestWB.Worksheets("addresses")

Set DestRange = DestSh.Range("b1:t500")

On Error Resume Next
For Each wks In Worksheets
wks.Unprotect Password:="nev"
Next wks

Then it works OK. It just will not copy the data from Source to Destination
sheets

Can anyone out there help? I have 80 workbooks to run from Personal!

Thanks in advance

Nev
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 320
Default Macro worts in workbook but not from Personal.xls

Most likely cuplrit is the use of "Thisworkbook" which now refers to your
personal.xls and which probably doesn't have a sheet named "Addresses"!
Change thisworkbook to Activeworkbook and all should be OK
Bob Umlas
Excel MVP

"Nev" wrote in message
...
Hi there

With help from community I have a great macro. Trouble is that this
section
will run in its own workbook but not when its in Personal.xls

Sub Copy_to_new_Workbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long

Macro then runs fine until after the option to save from here on

Application.Dialogs(xlDialogSaveAs).Show

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Change the file name (2*) and the path/file name to your file
If bIsBookOpen_RB("Master Copy.xls") Then
Set DestWB = Workbooks("Master Copy.xls")
Else
Set DestWB = Workbooks.Open("c:\block management\Master Copy.xls")
End If

'Change the Source Sheet and range
Set SourceRange = ThisWorkbook.Sheets("addresses").Range("b1:t500")
'Change the sheet name of the database workbook
Set DestSh = DestWB.Worksheets("addresses")

Set DestRange = DestSh.Range("b1:t500")

On Error Resume Next
For Each wks In Worksheets
wks.Unprotect Password:="nev"
Next wks

Then it works OK. It just will not copy the data from Source to
Destination
sheets

Can anyone out there help? I have 80 workbooks to run from Personal!

Thanks in advance

Nev



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro worts in workbook but not from Personal.xls

And to add to Bob's advice...

This line (after Bob's suggested change)
'Change the Source Sheet and range
Set SourceRange = Activeworkbook.Sheets("addresses").Range("b1:t500" )

Will refer to the activeworkbook. And if you just opened that "Master Copy.xls"
file, there's a good chance that "Master Copy.xls" is the activeworkbook.

I'd move that line before the bisbookopen() line:

....

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Change the Source Sheet and range
Set SourceRange = Activeworkbook.Sheets("addresses").Range("b1:t500" )

'Change the file name (2*) and the path/file name to your file
If bIsBookOpen_RB("Master Copy.xls") Then
Set DestWB = Workbooks("Master Copy.xls")
Else
Set DestWB = Workbooks.Open("c:\block management\Master Copy.xls")
End If

'Change the sheet name of the database workbook
Set DestSh = DestWB.Worksheets("addresses")

Set DestRange = DestSh.Range("b1:t500")

.....


Nev wrote:

Hi there

With help from community I have a great macro. Trouble is that this section
will run in its own workbook but not when its in Personal.xls

Sub Copy_to_new_Workbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long

Macro then runs fine until after the option to save from here on

Application.Dialogs(xlDialogSaveAs).Show

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Change the file name (2*) and the path/file name to your file
If bIsBookOpen_RB("Master Copy.xls") Then
Set DestWB = Workbooks("Master Copy.xls")
Else
Set DestWB = Workbooks.Open("c:\block management\Master Copy.xls")
End If

'Change the Source Sheet and range
Set SourceRange = ThisWorkbook.Sheets("addresses").Range("b1:t500")
'Change the sheet name of the database workbook
Set DestSh = DestWB.Worksheets("addresses")

Set DestRange = DestSh.Range("b1:t500")

On Error Resume Next
For Each wks In Worksheets
wks.Unprotect Password:="nev"
Next wks

Then it works OK. It just will not copy the data from Source to Destination
sheets

Can anyone out there help? I have 80 workbooks to run from Personal!

Thanks in advance

Nev


--

Dave Peterson
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
Personal Macro workbook BillD Excel Discussion (Misc queries) 2 October 19th 07 04:39 PM
Personal Macro Workbook Frustrated Excel Discussion (Misc queries) 2 August 17th 06 04:45 AM
Where is Personal Macro Workbook? fxcel Excel Discussion (Misc queries) 2 June 17th 06 02:26 PM
Personal macro workbook and personal.xls John Kilkenny Excel Discussion (Misc queries) 1 June 14th 05 09:43 PM


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