Vba Basic Flashcards
insert row
Rows(i & “:” & i ).Insert Shift:=xlDown
delete row
Rows(i & “:” & i).Delete shift:=xlUp
export table DB
Call JDdumpvariable2d(output,false)
open XML:
Workbooks.OpenXML “C:\TEMP\AMF\feedback_20150116.xml”
convert column number to letter
ColumnLetter = Split(Cells(1, ColumnNumber).Address, “$”)(1)
Loop function:
in RealTimeFunction
Application.OnTime Now + TimeValue(“00:00:10”), “RealTimeFunction”
save PDF:
ActiveSheet.Range(“B1:H60”).ExportAsFixedFormat Type:=xlTypePDF, fileName:=myFileName
insert image from net:
Sheets(1).Shapes.AddPicture “http://www.testsite.com/pix/temp1.png” , msoFalse, msoTrue, 100, 100, 500, 600
send email:
Dim olMail As Object Dim OlApp As Object Set OlApp = CreateObject("Outlook.Application") Set OlMail = OlApp.CreateItem(0) With OlMail .To = myTo .Subject = mySubject '.Body = myBody .htmlBody = myHTMLbody .Attachments.add myfullPath .Display End With
is file there:
isFileThere = (Dir(fileName) <> “”)
is Folder Exist
isFileThere = (Dir(myPath, vbDirectory) <> “”)
find all Files in folder:
fileName = Dir(myPath & "*.*") Do While fileName <> "" 'code fileName = Dir() Loop
try to create folder
On Error Resume Next
‘create folder
mkdir Location
On Error Goto 0
checkOpenFileName
Dim Wb As Workbook
For Each Wb In Workbooks
If InStr(Wb.Name, myFileName) <> 0 Then ‘found it
Next Wb
change in Worksheet event:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
mycolumn = Target.Cells.Column
myline = Target.Cells.Row