APOSTROPHE '
Rem Statement
Classification of Windows
Application Object
Dim FD As FileDialog
Set FD = Application.FileDialog(msoFileDialogFilePicker)
With FD
.Title = "Select The Workbook"
.AllowMultiSelect = False
.Filters.Add "Excel", "*.xlsx", 1
If .Show = -1 Then
MsgBox .SelectedItems(1)
Workbooks.Open (.SelectedItems(1))
Else:
MsgBox "Not Selected The File"
End If
End With
Application.AddCustomList listarray:=Array("A", "B", "C", "D", "E")
Sheet2.Range("D1").Value = "A"
Sheet2.Range("D1").AutoFill
Destination:=Range("D1:D5"), Type:=xlFillDefault
Range Object
Dim Rng As Range
Set Rng = Range("A15")
Set Rng = Range("A4:C16")
Set Rng = Cells(2, 1)
Set Rng = Range(Cells(2, 1), Cells(15, 5))
Rng.Select
Rng.Value = "abc"
Rng.Interior.ColorIndex = 11
Range("J8").Value = 10
Range("J8:J2").FillUp
Range("J8:J14").FillDown
Range("J8:C8").FillLeft
Range("J8:P8").FillRight
Rng.AdvancedFilter Action:=xlFilterCopy, copytorange:=Range("D1"), unique:=True
Sheets("Sheet2").Sort.SortFields.Clear
Sort.SortFields.Add Key:=Range("B1"), SortOn:=xlSortOnValues, _
Order:=xlAscending
With ThisWorkbook.Sheets("Sheet2")
Sort.SetRange Range("A1").CurrentRegion
.Sort.Header = xlYes
.Sort.MatchCase = False
.Sort.Orientation = xlSortColumns
.Sort.Apply
End With
With Sh.Range("L5:Q6")
Dim Shp As Shape
Set Shp = Sh.Shapes.AddShape(Type:=msoShapeRectangle, _
Left:=.Left, _
Top:=.Top, _
Width:=.Width, _
Height:=.Height)
End With
returns first occurace number Here output = 3
For i = 1 To Len(word)
If Mid(word, i, 1) = "a" Or _
Mid(word, i, 1) = "u" Or _
Mid(word, i, 1) = "n" Then
result = result & Mid(word, i, 1)
Range("B1").Value = result
End If
Next
For i = 1 To Len(Data)
If Mid(Data, i, 1) Like "[0-9]" Then
numb = numb + Mid(Data, i, 1)
Cells(r, 2).Value = numb
ElseIf UCase(Mid(Data, i, 1)) Like "[A-Z]" Then
str = str + Mid(Data, i, 1)
Cells(r, 3).Value = str
ElseIf Not Mid(Data, i, 1) Like "[0-9]" Or UCase(Mid(Data, i, 1)) Like "[A-Z]" Then
spechar = spechar + Mid(Data, i, 1)
Cells(r, 4).Value = spechar
End If
Next
For i = 1 To Len(j)
If IsNumeric(Mid(j, i, 1)) Then
numb = numb & Mid(j, i, 1)
Cells(r, 2) = numb
ElseIf Not IsNumeric(Mid(j, i, 1)) Then
stri = s
tri & Mid(j, i, 1)
Cells(r, 3) = stri
End If
Next
Range Object
Worksheet Functions
Dim KeyValue As Variant
For Each KeyValue In Dict.Keys
MsgBox Dict(KeyValue)
Next
Dim pc As PivotCache
Set pc = ActiveWorkbook.PivotCaches.Create(xlDatabase, Rng)
Dim Pv As PivotTable
Set Pv = pc.CreatePivotTable(Range("H3"), tablename:="information")
With Pv
.PivotFields("Item").Orientation = xlRowField
.PivotFields("location").Orientation = xlColumnField
.PivotFields("Company").Orientation = xlPageField
With .PivotFields("Quantity")
.Orientation = xlDataField
.Function = xlSum
End With
With cb
.Name = "myname"
.Left = Columns("B:E").Left
.Width = Columns("B:E").Width
.Height = Rows("10:11").Height
.Top = Rows("10:11").Top
End With
Dim b As Button
Set r = Range("G" & n)
Set b = ActiveSheet.Buttons.Add(r.Left, r.Top, r.Width, r.Height)
b.Caption = "button" & i
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
SH.Cells(r, 1).Value = Me.ListBox1.List(i, 0)
SH.Cells(r, 2).Value = Me.ListBox1.List(i, 1)
SH.Cells(r, 3).Value = Me.ListBox1.List(i, 2)
SH.Cells(r, 4).Value = Me.ListBox1.List(i, 3)
SH.Cells(r, 5).Value = Me.ListBox1.List(i, 4)
r = r + 1
End If
Next
With Me.ListBox1
.Clear
.Font.Size = 14
.Font.Name = "Calibri"
.ColumnCount = 5
.ColumnHeads = True
.RowSource = "Sheet2!A2:F" & LastRow
.ListStyle = fmListStyleOption
.MultiSelect = fmMultiSelectMulti
.TextAlign = fmTextAlignCenter
End With
Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject
Dim FilePath As String
FilePath = "C:\Test\Samples.xlsx"
If FSO.FileExists(FilePath) = True Then
Workbooks.Open (FilePath)
Else:
MsgBox "Workbook doesn't exists in the below mentioned path" & vbNewLine & FilePath
End If
Dim ConnectionString As String
ConnectionString = "Provider=SQLOLEDB;Data Source=PAVAN-PC;Initial Catalog=Excel_Access_SQL;Integrated Security=SSPI"
Con.Open ConnectionString
Con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & FileName & ";" & _
"User Id=admin;Password="
Con.Open
With rs
.AddNew
.Fields("Student Name") = UserForm1.TextBox1.Value
.Fields("Roll No") = UserForm1.TextBox2.Value
.Fields("Class") = UserForm1.TextBox3.Value
.Fields("Science") = UserForm1.TextBox4.Value
.Fields("Social") = UserForm1.TextBox5.Value
.Fields("Maths") = UserForm1.TextBox6.Value
.Fields("GK") = UserForm1.TextBox7.Value
.Update
End With
rs.Close