Thank you for Visiting my Blog

Sunday, 15 October 2017

How Split Functon works


Split Function:
Description:

Returns a zero-based, one-dimensional array containing a specified number of substrings.

Syntax:

Split(expression[, delimiter[, limit[, compare]]])

Arguments:

PartDescription
expressionRequired. String expression containing substrings and delimiters. If expression is a zero-length string(""), Split returns an empty array, that is, an array with no elements and no data.
delimiterOptional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
limitOptional. Number of substrings to be returned; –1 indicates that all substrings are returned.
compareOptional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.
 
Example :


Sub SplitFn()

Dim Strname() As String

Strname = Split("HELLO WORLD")

MsgBox (Strname(0) & Chr(10) & Strname(1))

End Sub

Thursday, 12 October 2017

How to open any file using marcos



To open any file which is placed at any location in system please use below code:


Below example both file is placed at the same location . so I am directly reading directory name but if you want to get from other location you can modify the code.


Sub fileopen()
Dim fname As String, wbTarget As Workbook
''''''/**********provide the filename which need to open ***********/''''''''''

fname = InputBox(Prompt:="Name of the file:", _
    Title:="Please Enter file name", Default:="myfile.xlsx")

''''''/**********filelocation can be get by User ***********/''''''''''


Filename = ActiveWorkbook.Path & "\" & fname

''''''/*********below is the function to open the file ***********/''''''''''

Set wbTarget = Workbooks.Open(Filename)

End Sub

 Input#



 Output#