Skip to main content

Posts

Showing posts from February, 2015

Targeting Sendkeys to a Particular Window using Excel VBA

Hi Everyone, Sometimes while doing some VBA stuff, we want to target Sendkeys to a particular window which may or may not be active or present. Here is the code which will first check if the Target window is available by trying to activate it by AppActivate and then Sendkeys as desired. If Target window isn't available then you may wait until it shows up or show an error message. So Here are the code:- 1. For waiting until Windows shows up:- Sub Target_Sendkeys() On Error Resume Next 'Resuming next Statement on Error(5) Do Err.Clear 'Reseting the Err AppActivate "Blogger" 'Put the name of title bar of Target window here. DoEvents 'Avoidings hangs Loop While Err.Number = 5 SendKeys "%{ }r", True 'Restoring the window Application.Wait DateAdd("s", 1, Now) '

Auto Refreshing/Updating External workbook links after x intervals

Hi Everyone, In this article, I have explained that how you can force Excel to update External workbook links after a fixed interval or instantly. This involves a VBA code, so make sure to Enable Macros while opening workbook to get this done. Actually, I have used a Workbook_Open Event to initialise the Update_Links Subroutine and an Ontime Event that will recall the Update_Links Subroutine after an interval. So here we go:- Steps:- 1. Open your Target workbook which contains External links to other workbooks. 2. Press Alt + F11. Double Click ThisWorkbook Module. Copy and Paste the following code there:- Private Sub Workbook_Open() Call Update_Links End Sub

Creating Multiple Drop Downs with No Repetition of Values

Hi Everyone, I think the picture explains everything whats gonna be in this articles. Yes, Multiple dropdowns with no Repetited Values with only one helper column And lesser and quite easy steps. So here we go. First we will make some Named Ranges to Capture the Players Pool and Selected Pool. Use Following Non Volatile Dynamic Named Ranges which will Expand and Contract those Pools when Data is added or cut off.

Converting Numbers or Date stored in Text format to Number or Date format

Hi Everyone, Sometimes we export data from our Softwares to Excel files and find that some data is looking as Numbers but not behaving as Numbers and same is the case with Dates as well. Here in this article, I have tried to overcome this problem with a procedure OR code which will convert the Numbers and Dates stored in Text format to their respective formats. Here are the steps:- 1. Select the Range. The Range should be one columnar Range. Preferably select whole column at a time. 2. Click "Text to Column" Option in Data Tab. 3. Select "Delimited" Option, and click Next. Uncheck all the Dilimiter options. 4. Click Next Again and then click Finished. That it. Now, you will notice that the format has changed.

Excel VBA - E-Mailing a Selection, Range or whole worksheet (as Email Body)

Hi Everyone, I will start straight away with the code as Purpose is very much clear from the Title. Sending worksheet as Attachment is one way of doing that. But there are some extra steps involved and presentation is another reason why I am choosing this code over manual steps. The following code will mail the desired table or ranges or the whole worksheet to the desired recipients. So here are the the codes:- 1. For Selection  Select a range of cells to be mailed and run the following code:- Sub Mail_Selection_Worksheet() ActiveWorkbook.Save 'Saving workbook to counter '"the MailEnvelope method of Worksheet object failed" error With ActiveSheet.MailEnvelope 'Creating an Email Environment. .Introduction = "Add your Introduction here." With .Item 'Creating a MailItem .To