Skip to main content

Posts

Showing posts with the label macro code example

Insert Names Across Rows Using Macro,Open Sheet is in the Home Position,Export Camera Picture,Convert Dates- excel Tips

Insert Names Across Rows Using Macro in excel  standard module Sub Test() Dim x As Worksheet Application.DisplayAlerts = False On Error Resume Next Sheets("DataSheet").Delete Names("Data").Delete Application.DisplayAlerts = True On Error GoTo 0 Sheets.Add().Name = "Datasheet" Dim nm As Name Dim i As Long Dim avarSplit As Variant Dim noPage As Variant i = 1 Application.ScreenUpdating = False With Sheets("DataSheet") For Each nm In Names .Cells(1, i) = nm.Name .Cells(2, i) = "'" & nm.RefersTo .Cells(3, i) = nm.Value 'noPage = Split( ????? i = i + 1 Next nm End With Columns("A").Resize(, i).AutoFit End Sub '- ' in workbook module edd: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Call Test End Sub '--   Code to The W...

Excel Macro to paste all the images in excel book one after the other

Excel Macro to paste all the images in excel book one after the other Dim MyFolder As String, fn As String, i As Long MyFolder = "C:\Pictures\" If Right$(MyFolder, 1) <> "\" Then MyFolder = MyFolder & "\" fn = Dir(MyFolder & "*.jpg") i = 2 Do While fn <> "" Set p = ActiveSheet.Pictures.Insert(MyFolder & fn) p.Top = i i = i + p.Height + 5 fn = Dir() Loop End Sub

Excel macro to send mail automatically

Excel  macro to send mail automatically Summary : This is example of macro which helps to send mail automatically with attachment of entire Workbook and pasting one particular sheet in the mail body. Function RangetoHTML(rng As Range) ' Changed by Ron de Bruin 28-Oct-2006 ' Working in Office 2000-2010 Dim fso As Object Dim ts As Object Dim TempFile As String Dim TempWB As Workbook TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm" 'Copy the range and create a new workbook to past the data in rng.Copy Set TempWB = Workbooks.Add(1) With TempWB.Sheets(1) .Cells(1).PasteSpecial Paste:=8 .Cells(1).PasteSpecial xlPasteValues, , False, False .Cells(1).PasteSpecial xlPasteFormats, , False, False .Cells(1).Select Application.CutCopyMode = False On Error Resume Next .DrawingObjects.Visible = True ...