Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Open another workbook and then some.... from another Workbook !!

Code when opening
Private Sub Workbook_Open()
Macro5
End Sub


and


code for Macro5

Sub Macro5()
'
' Macro1 Macro
' Macro recorded 20/06/2006 by Corey
'
Dim sh As Worksheet
Dim msg As String, sName As String
msg = "Enter the Next Quote Number...."
Do
sName = InputBox(msg)
If sName = "" Then Exit Sub
On Error Resume Next
Set sh = Worksheets(sName)
On Error GoTo 0
msg = "Quote Number has been used, try again: "
Loop While Not sh Is Nothing
With ActiveWorkbook
.Worksheets("STQ Template").Copy After:=.Worksheets(.Worksheets.Count)
End With
ActiveSheet.Name = sName
[I12].Select
ActiveCell.Value = sName

'
End Sub




To the above i am trying to have a MAX value of [I12] in ALL sheets,
displayed on the sheet that originally opens and this wil be the next number
to enter into the msg box above in Macro5
Not able to as yet, still manually doing this.

Regards

Corey


"Norman Jones" wrote in message
...
Hi Corey,

In order to copy to the newly crated sheet, it is necessary to know either
the name of the new sheet or its position.

IMO, the best option is to adopt my original suggestion, and create the
new sheet as part of the button code in the first workbook. Alternatively,
post the 2nd workbook open event code which creates the new sheet and I
will adapt the suggested current code.


---
Regards,
Norman



"Corey" wrote in message
...
Ok, thanx
I get a little way down the code before i get another error in:
Set destSH = .WB.Sheets("100101")
The "100101" is a value i placed in there, but assuming that it refers to
the Newly created sheet in wb2.
I have another macro that creates this and a msg box that gives the sheet
name value.
Can this be adapted to suit somehow?

Regards

Corey





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Open another workbook and then some.... from another Workbook !!

Hi Corey,

Try therefo

'=============
Private Sub Tester()
Dim WB As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet
Dim srcRng As Range
Dim destRng As Range
Const sName As String = "MyNewSheet" '<<==== CHANGE

Set srcSH = ThisWorkbook.Sheets("Sheet1") '<<==== CHANGE
Set srcRng = srcSH.Range("A1:D10") '<<==== CHANGE

Set WB = Workbooks.Open(Filename:= _
"C:\B\AA\Test2.xls") '<<==== CHANGE

With WB
Set destSH = .Sheets(.Sheets.Count)
Set destRng = destSH.Range("B1") '<<==== CHANGE
srcRng.Copy Destination:=destRng
.Close SaveChanges:=True
End With
End Sub
'<<=============


I do not understand:

To the above i am trying to have a MAX value of [I12] in ALL sheets,
displayed on the sheet that originally opens and this wil be the next
number to enter into the msg box above in Macro5
Not able to as yet, still manually doing this.


However, this should have no bearing on your original question or the
suggested code.

---
Regards,
Norman



"Corey" wrote in message
...
Code when opening
Private Sub Workbook_Open()
Macro5
End Sub


and


code for Macro5

Sub Macro5()
'
' Macro1 Macro
' Macro recorded 20/06/2006 by Corey
'
Dim sh As Worksheet
Dim msg As String, sName As String
msg = "Enter the Next Quote Number...."
Do
sName = InputBox(msg)
If sName = "" Then Exit Sub
On Error Resume Next
Set sh = Worksheets(sName)
On Error GoTo 0
msg = "Quote Number has been used, try again: "
Loop While Not sh Is Nothing
With ActiveWorkbook
.Worksheets("STQ Template").Copy After:=.Worksheets(.Worksheets.Count)
End With
ActiveSheet.Name = sName
[I12].Select
ActiveCell.Value = sName

'
End Sub




To the above i am trying to have a MAX value of [I12] in ALL sheets,
displayed on the sheet that originally opens and this wil be the next
number to enter into the msg box above in Macro5
Not able to as yet, still manually doing this.

Regards

Corey



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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation Marcello do Guzman[_3_] Excel Programming 2 December 5th 04 06:50 AM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


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