Tuesday, July 26, 2011

Code for creating file on specified path (Share Certificate)

Sub Share_Certificate()
'
' Share_Certificate Macro    Dim newname As Variant
    Sheets("1 PG").Select
    Sheets("1 PG").Copy After:=Sheets(3)
    ActiveSheet.Select
    newname = Range("D19").Value
    ActiveSheet.Name = newname
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("B3:E5").Select
    Application.CutCopyMode = False
    Sheets("Master").Select
   
End Sub


Sub New_File()
'
' Macro1 Macro
'
    Dim Fpath As String
    Dim Fname As Variant
   
   
    Sheets(Array("1 PG", "2 PG")).Select
    Sheets("1 PG").Activate
    Sheets(Array("1 PG", "2 PG")).Copy
    Sheets("1 PG").Select
    Fname = Range("D19").Value & "Share Certificate.xls"
    Application.DisplayAlerts = False
    ActiveWorkbook.CheckCompatibility = False
        Fpath = InputBox("Kindly provide folder address where you want to save your file", "")
    ActiveWorkbook.SaveAs Filename:= _
        Fpath & Fname, FileFormat:=xlExcel8, _
        Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
        CreateBackup:=False
    ActiveWindow.Close
    Sheets("Master").Select
   
End Sub

No comments:

Post a Comment