Showing posts with label Macro. Show all posts
Showing posts with label Macro. Show all posts

Friday, October 14, 2011

Get Last Column Number

if you want to get last column number thn use this code ...

LastColumnNumber=Range("A1").end(xlToRight).Column



Get last row number

 use this code to get last row number in variable.....

LastRowNumber = Range("A1").End (XlDown).Row


This code work when you data in column "A" , if your data in another column thn you hav to change your column in range......



Thursday, October 13, 2011

Use excel formulas to get direct values in variable

if you want to use formula directly in vba with out putting your figures in any cell then do like this.
suppose you want minimum value of  range cell "A1 To A10" in a variable
then write your code:-

minv= WorksheetFunction.Min(range("a1:a10"))

Saturday, October 8, 2011

How to mail through VBA from Outlook

With help this macro code you can mail easily from outlook in just a single click....


Sub Mail ()
ESubject = "Mail Subject"
SendTo = "email-id"
CCTo = "email-id"
'Ebody = "TEST MAIL"
Ebody = "Mail Body"
newfilename = " The complete Path of file that to mail"
Set App = CreateObject("Outlook.Application")
Set Itm = App.CreateItem(0)
With Itm
.Subject = ESubject
.To = SendTo
.CC = CCTo
.Body = Ebody
.Attachments.Add newfilename
.send
End With
Set App = Nothing
Set Itm = Nothin
End Sub ()