Sunday, February 10, 2013

Change the formatting of text to match the your style in Excel while doing copy-paste

 If you want to copy-paste text and want it should copy-paste automatically matching your style , then  copy the below code in "thisworkbook" of you excel


Private Sub WorkBook_Open()

  'MsgBox "this happens when workbook is opened"
    Application.OnKey "^v", "my_paste"
    '--------------call macro Paste option set to my style
End Sub
Option Explicit

Sub my_paste()
    MsgBox "you have pressed ctrl+v"
'Enter the password if your sheet is protected .
'worksheet.Protect Password:="urPassword", UserInterFaceOnly:=True, AllowFormattingColumns:=True, AllowFiltering:=True

'enter here your sheet style which is to be matched.
        Selection.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
        False, NoHTMLFormatting:=True, SkipBlanks:=False, Transpose:=False
   
End Sub

No comments:

Post a Comment