View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
[email protected] michele@quality-computing.com is offline
external usenet poster
 
Posts: 19
Default Msgbox to make a choice

Hi Greg,

It works now. It was that trusted sources thing. I had to check
'Trust access to Visual Basic Project'.

It works as a separate macro, but I'd still like to include it at the
top of mine. Since I don't know where to put the top two lines, I'm
confused as to what to do.

Here is my macro. I'd like to replace the 'Which company to do quote
for?' section with your much better code.

Sub Quote()
'
' Quote Macro
' Macro recorded 5/17/2005 by Michele J. Jones
'
' Keyboard Shortcut: Ctrl+q

' Which company to do quote for?
Const qfPath = "C:\Documents and Settings\John\My
Documents\quoteprogramfiles\"
Dim qfFileName As String
Dim vResponse As Variant
If MsgBox("Is quote for Custom Safety?", vbYesNo + vbQuestion,
"Quoting Company") = vbYes Then
qfFileName = "CSQuoteform.xls"
Else
qfFileName = "STQuoteform.xls"
End If

' Quit if quote is open and open if not
If IsFileOpen(qfPath & qfFileName) Then
MsgBox "Quote form is open. Save and close form " & qfFileName
& " and try again."
Exit Sub
Else
Workbooks.Open qfPath & qfFileName
End If

' Go to CUST column A and copy fields
Windows("cust.xls").Activate
Selection.End(xlToLeft).Select
Dim fn
Dim ln
Dim cm
Dim a1
Dim a2
Dim ci
Dim pr
Dim pc
Dim ph
Dim fx
fn = ActiveCell.Value
Selection.Offset(0, 1).Select
ln = ActiveCell.Value
Selection.Offset(0, 1).Select
cm = ActiveCell.Value
Selection.Offset(0, 1).Select
a1 = ActiveCell.Value
Selection.Offset(0, 1).Select
a2 = ActiveCell.Value
Selection.Offset(0, 1).Select
ci = ActiveCell.Value
Selection.Offset(0, 1).Select
pr = ActiveCell.Value
Selection.Offset(0, 1).Select
pc = ActiveCell.Value
Selection.Offset(0, 1).Select
ph = ActiveCell.Value
Selection.Offset(0, 1).Select
fx = ActiveCell.Value

' Position CUST on First Name
Selection.Offset(0, -9).Select

' Paste FirstName and LastName
Windows(qfFileName).Activate
Range("B11").Select
Selection = fn
Selection.Offset(0, 1).Select
Selection = ln

' Join First and Last Names
Selection.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-2],"" "",RC[-1])"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy

' Past Joined Name
Selection.Offset(0, -2).Select
ActiveSheet.Paste

' Remove OldJoined Name
Selection.Offset(0, 2).Select
Selection.ClearContents

' Remove Old LastName
Selection.Offset(0, -1).Select
Selection.ClearContents

' Paste Company, Address1, Address2, City, Prov & PC
Selection.Offset(-5, -2).Select
Selection = cm
Selection.Offset(1, 0).Select
Selection = a1
Selection.Offset(1, 0).Select
Selection = a2
Selection.Offset(1, 0).Select
Selection = ci
Selection.Offset(0, 1).Select
Selection = pr
Selection.Offset(0, 1).Select
Selection = pc

' Join City, Prov PC
Selection.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-3],"", "",RC[-2],""
"",RC[-1])"

' Make City, Prov PC into a value
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False

' Clear PC, Prov & City
Selection.Offset(0, -1).Select
Selection.ClearContents
Selection.Offset(0, -1).Select
Selection.ClearContents
Selection.Offset(0, -1).Select
Selection.ClearContents

' Merge City, Prov & PC Cells
Range("A9:C9").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With

' Copy City, Prov PC
Range("D9").Select
Selection.Copy

' Paste City, Prov PC
Range("A9").Select
ActiveSheet.Paste

' Clear Old City, Prov PC
Range("D9").Select
Selection.ClearContents

' Paste Phone & Fax
Selection.Offset(3, -1).Select
Selection = ph
Selection.Offset(1, 0).Select
Selection = fx

' Position Quote on Company
Selection.Offset(-7, -1).Select

End Sub

If you're an amateur, I'm in real trouble, but alas, this is not my
only day job.

Thanks again,

Michele