Friday, June 3, 2016

Excel Tutorial (Macros and PivoTable)


These blog is to help people like me that are starting to develop Macros in Excel VB.

You can find the video tutorials in the following link:

Playlist RITEC Channel


First TIP.

Have you ever had a problem with the automatitation in Excel with the dates in the PivoTable?
Here the solution.

Group and Ungroup Pivotable Excel 2013, 2014, 2015, 2016


Second TIP.

Enable Developer Tab and start recording Macros.

How to Record a Macro in Excel, enable Developer Tab in Excel. 

Third TIP

Take a picture of a Sheet and save it as a JPG file


If you need the original code go to this link.
Picture
http://stackoverflow.com/questions/16143877/using-vba-code-how-to-export-excel-worksheets-as-image-in-excel-2003

Delay
http://stackoverflow.com/questions/1544526/how-to-pause-for-specific-amount-of-time


Code: 
Sub photo()

Dim sSheetName As String
Dim oRangeToCopy As Range
Dim oCht As Chart
Dim x As String
Dim y As String
Dim namechart As String


Sheets("Graph").Select
x = Application.ActiveWorkbook.path
y = Cells(2, 3)
Sheets("Graph").Range("A1:W35").CopyPicture xlScreen, xlBitmap
Set oCht = Charts.Add
Application.Wait (Now + #12:00:01 AM#)

With oCht
    .Paste
    'to avoid to have a white picture
    Application.Wait (Now + #12:00:02 AM#)
    .Export Filename:=x & "\" & y & ".jpg", Filtername:="JPG"
    'to avoid to have a white picture
    Application.Wait (Now + #12:00:02 AM#)
End With

'the picture is  pasted in a new Chart sheet
'so this one need to be deleted
namechart = ActiveSheet.Name
Sheets(namechart).Select
ActiveWindow.SelectedSheets.Delete

End Sub

No comments:

Post a Comment