VBA for Excel - PowerPoint PPT Presentation

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Presentation

PowerPoint Slideshow about 'VBA for Excel' - kasi

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

Private Sub CommandButton3_Click()'to get the year of a date. Dim exampleDate As Date 'First, we declare a date using the Dim statementexampleDate = DateValue("Jun 19, 2010") 'To initialize a date, we use the DateValue functionMsgBox Year(exampleDate)'To add a number of days to a date, use the DateAdd function Dim firstDate As Date, secondDate As DatefirstDate = DateValue("Jun 19, 2010")secondDate = DateAdd("d", 3, firstDate) '"d" to "m" to add a number of months to a dateMsgBoxfirstDate & vbNewLine & secondDate'msgboxfirstDate en secondDate op de volgenderegel Range("A9").Value = firstDate'place the value assigned to the variable firstDate in cel A9 Range("A10").Value = secondDate 'place the value assigned to the variable secondDate in cel A10MsgBox Date & " is present date" 'To get the current dateMsgBox Now 'To get the current date and time, use the Now functionMsgBox Hour(Now) 'gets the hour of the current time'TimeValue 'The TimeValue function converts a string to a time serial number. The time's serial number is a number between 0 and 1. 'For example, noon (halfway through the day) is represented as 0.5.MsgBoxTimeValue(Now) Dim y As Double y = TimeValue("12:10:01")MsgBox y & " this is time as a numbers between 0 and 1"End Sub

IF Then Else Private Sub CommandButton7_Click() 'nu een if met Else Statement Dim score As Integer, grade As String score = Range("A11").Value If score >= 6 Then 'start a new line after the words Then and Else and end with End If ' grade = "voldoende" Else grade = "onvoldoende" End If Range("B12").Value = gradeEnd Sub Cells Instead of the Range objectPrivate Sub CommandButton8_Click()'Instead of the Range object, you can also use Cells 'For example, Cells(4,2).value is the same as Range("B4").value. rownumber 4 and columnnumber 2 'using Cells is particularly useful when we want to loop through ranges (wordt later behandeld) Cells(4, 2).Value = 100End Sub