Thanks for the help.It worked the first time. As I mentioned in the original
post, I am a rookie at this. I basically use the macro recorder to create
code and the view it to try and understand it.
The code you provided works great, although a have a bug that I am not sure
how to fix. I will try to explain.
The code you provided activates a macro that initiates a message box. If the
user clicks yes, this activates another macro that copies the contents of the
cell within the range as well as an adjacent cell. When this macro runs it
reactivates the code behind the worksheet forcing the user to click no this
time to alleviate the code running again and again. Below is the some of the
code I used.
First the Worksheet code.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static NotInLastTime As Boolean
If Target.Cells.Count > 1 Then
Exit Sub
End If
If Application.Intersect(Target, Range("Vendor1")) Is Nothing Then
If NotInLastTime = False Then
Application.Run "'P.O. Log.xls'!IntiateMsgbox"
NotInLastTime = True
End If
Else
NotInLastTime = False
End If
End Sub
--------------------------------------------------------------------------------------
The Code for the initiate Msgbox is 2 Parts. the first is like this.
Sub IntiateMsgbox()
'
' IntiateMsgbox Macro
'This macro initiates the message box and when yes is clicked it creates the
new purchase order.
Answer = MsgBox(Prompt:="Create New Purchase Order?", Buttons:=vbYesNo)
If Answer = vbYes Then
Application.Run "'P.O. Log.xls'!SetupPO"
End If
End Sub
-----------------------------------------------------------------------------------------------
The code for SetupPO looks like this.
Sub SetupPO()
'
' SetupPO Macro
' Macro recorded 10/11/2007
'This macro wo\rks to open the template, label it and save it correctly. Do
not change it.
Workbooks.Open Filename:="G:\RickB\P.O. & Sub\New PO.xls", UpdateLinks:=3
Windows("P.O. Log.xls").Activate
ActiveCell.Offset(0, -2).Range("A1").Select
Selection.Copy
Windows("New PO.xls").Activate
Range("F13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Windows("P.O. Log.xls").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("New PO.xls").Activate
Range("C16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("N17").Select
ActiveWorkbook.SaveAs Filename:="G:\RickB\P.O. & Sub\" &
ActiveCell.Text, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub
------------------------------------------------------------------------------------------------
I suspect the problem originates in the SetupPO code. There is probably a
better way of creating the code needed to perform this operation. As I said
in the beginning, your solution works fine. it is somethin that I am doing
wrong on my end.
Thanks,