VBA Code Library

March 28, 2017 | Author: Balaji.S (ACA) Srirangam | Category: N/A
Share Embed Donate


Short Description

Download VBA Code Library...

Description

http://www.vbusers.com/code/codetoc.asp http://www.vbusers.com/downloads/download.asp http://www.freevbcode.com/ShowCode.asp?ID=329 http://allenbrowne.com/funcindex.html http://www.ozgrid.com/VBA/ http://www.mrexcel.com/forum/excel-questions/540096-use-visual-basic-applications-code-create-excel-drop-do

vip

http://www.mrexcel.com/forum/excel-questions/643359-visual-basic-applications-code-sort-list-then-delete-sim http://www.mrexcel.com/forum/excel-questions/649127-visual-basic-applications-using-block-code-filtered-list.h http://msdn.microsoft.com/en-us/library/aa984063(v=vs.71).aspx http://www.mrexcel.com/forum/excel-questions/540096-use-visual-basic-applications-code-create-excel-drop-do http://www.mrexcel.com/forum/excel-questions/649127-visual-basic-applications-using-block-code-filtered-list.h http://www.ozgrid.com/VBA/ http://www.mrexcel.com/articles.shtml http://www.mrexcel.com/articles.shtml#Formulas http://allenbrowne.com/funcindex.html http://www.mrexcel.com/articles.shtml#VBA http://www.mrexcel.com/forum/excel-questions/649127-visual-basic-applications-using-block-code-filtered-list.h http://www.mrexcel.com/forum/excel-questions/614216-visual-basic-applications-code-extract-list-unique-value http://www.mrexcel.com/forum/excel-questions/641873-visual-basic-applications-reorder-columns-list-view.htm http://www.mrexcel.com/forum/excel-questions/43009-visual-basic-applications-code-autofilter.html

http://www.vbusers.com/code/codetoc.asp?Search=&Type=0&MaxThread=395&MaxPost=1

cations-code-create-excel-drop-down-list.html

ons-code-sort-list-then-delete-simliar-rows-only-one-column.html ons-using-block-code-filtered-list.html

cations-code-create-excel-drop-down-list.html ons-using-block-code-filtered-list.html

ons-using-block-code-filtered-list.html ons-code-extract-list-unique-values-database-field.html ons-reorder-columns-list-view.html ns-code-autofilter.html

Returning a distinct list of items from an Excel Range Below is code to return a distinct list of items from an excel range.

Option Explicit 'Purpose : Returns a list of distinct items from a range. 'Inputs : rngReturnDistinctListFrom. The range to return the distinct list from ' rngItemsAlreadyReturned. The range containing the values already returned. 'Outputs : Returns the first distinct item which has not already been returned in the rngItemsAlreadyReturned range. 'Author : Andrew Baker 'Date : 25/03/2000 'Example usuage: ' '=FirstDistinctItem(A1:A1000,B$1:B1) 'Where: 'A1:A1000 is a list containing the items to return a distinct list of 'B$1:B1 is the list containing the distinct items already returned.

Function FirstDistinctItem(rngReturnDistinctListFrom As Excel.Range, rngItemsAlreadyReturned As Excel.Range, Optional bIgn Dim avItemsAlreadyReturned As Variant Dim vCell As Variant FirstDistinctItem = "" avItemsAlreadyReturned = rngItemsAlreadyReturned.Value For Each vCell In rngReturnDistinctListFrom If (bIgnoreBlanks = False Or (bIgnoreBlanks And vCell "")) = True Then If (ArrayHasItem(avItemsAlreadyReturned, vCell) = False) Then FirstDistinctItem = vCell Exit Function End If End If Next End Function 'Purpose : Checks to see if a value is already in an array. 'Inputs : avInArray. The array to evaluate. ' vValueToCheck. The value to look for in the array. 'Outputs : True. The array contains vValueToCheck ' False. The array does not contain vValueToCheck. 'Author : Andrew Baker 'Date : 25/03/2000 'Notes : The array can be any size or shape as this function

Function ArrayHasItem(avInArray As Variant, vValueToCheck As Variant) As Boolean Dim vThisItem As Variant, lThisRow As Long On Error GoTo ErrExit If ArrayNumDimensions(avInArray) = 1 Then 'Faster than for each loop For lThisRow = LBound(avInArray) To UBound(avInArray) vThisItem = avInArray(lThisRow) 'Check for arrays in arrays If IsArray(vThisItem) Then 'Search an array in an array If ArrayHasItem(vThisItem, vValueToCheck) Then 'Found item ArrayHasItem = True Exit For End If ElseIf vThisItem = vValueToCheck Then ArrayHasItem = True Exit For End If Next Else For Each vThisItem In avInArray 'Check for arrays in arrays If IsArray(vThisItem) Then 'Search an array in an array If ArrayHasItem(vThisItem, vValueToCheck) Then 'Found item ArrayHasItem = True Exit For End If ElseIf vThisItem = vValueToCheck Then ArrayHasItem = True Exit For End If Next End If ErrExit: On Error GoTo 0 End Function

'Purpose : Calculates the number of dimensions in an array 'Inputs : avInArray. The array to evaluate.

'Outputs : The number of dimensions the array has. 'Author : Andrew Baker 'Date : 25/03/2000 'Notes : Function ArrayNumDimensions(avInArray As Variant) As Long Dim lNumDims As Long If IsArray(avInArray) Then On Error GoTo ExitSub Do lNumDims = UBound(avInArray, ArrayNumDimensions + 1) ArrayNumDimensions = ArrayNumDimensions + 1 Loop End If ExitSub: On Error GoTo 0 End Function

n Excel Range

emsAlreadyReturned range.

ned As Excel.Range, Optional bIgnoreBlanks As Boolean = True) As Variant

How to use SHOWIF and SHOWUNLESS functions in Excel http://www.blog.methodsinexcel.co.uk/category/vba/

This post is by guest blogger Yoav Eze, his bio can be fond at the bottom of the post. Thanks Yoav! It’s always nice to get content from other Excel developers, so if you have an interesting story, please feel free to share it h That now makes a list of 2 guest bloggers on MIE in 5 years, Sam and Yoav, I’m hoping to grow that list!!! Now, over to Yoav.

Have you ever in your spreadsheets wanted to show a value only under certain conditions? We’ve created two functions show-functions (DOWNLAOD THE WORKBOOK HERE) that will do exactly this. The first accepts a

The second function does exactly the same, except that it will return the value if the condition is NOT met, and an empty strin Here’s an example of how you might use these functions. This is a formula used in one of our spreadsheets: =IF((SUMIFS(Payments!$D$2:$D$1000,Payments!$C$2:$C$1000,"="&B$1, OFFSET(Payments!$D$2:$D$1000,0,MATCH($A3,Payments!$E$1:$Z$1,0)),"x") SUMIFS(Payments!$D$2:$D$1000,Payments!$C$2:$C$1000,"="&$A3, OFFSET(Payments!$D$2:$D$1000,0,MATCH(B$1,Payments!$E$1:$Z$1,0)),"x"))
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF