+ Reply to Thread
Results 1 to 2 of 2

Provide user defined function for below vba code

Hybrid View

  1. #1
    Registered User
    Join Date
    08-16-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    28

    Provide user defined function for below vba code

    please provide user defined function for below code this code is to generate sheet automatically of filter value. i also attached the file where this code apply

    thanks



    Option Explicit
    Sub Copy_To_Workbooksmod()

    Dim Rng As Range, x, i&
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

    Set Rng = Sheets("ALL BANK 2012").Range("A1:G" & Sheets("ALL BANK 2012").Range("A" & Rows.Count).End(xlUp).Row)

    Rng.Parent.AutoFilterMode = False

    With CreateObject("Scripting.Dictionary")
    .CompareMode = 1

    x = Sheets("ALL BANK 2012").Range("A1:G" & Sheets("ALL BANK 2012").Range("A" & Rows.Count).End(xlUp).Row)
    For i = 2 To UBound(x)
    If Len(x(i, 6)) Then
    If Not .Exists(Trim$((x(i, 6)))) Then
    .Item(Trim$(x(i, 6))) = Empty

    Rng.AutoFilter 6, "=" & Replace(Replace(Replace(x(i, 6), "~", "~~"), "*", "~*"), "?", "~?")

    If Not Evaluate("ISREF('" & x(i, 6) & "'!A1)") Then
    Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = x(i, 6)
    Else
    Sheets(x(i, 6)).UsedRange.ClearContents
    End If
    With Worksheets(x(i, 6))
    Rng.SpecialCells(xlCellTypeVisible).Copy
    .Range("A1").PasteSpecial xlPasteValues
    .Range("A1").PasteSpecial xlPasteFormats
    .Columns.AutoFit
    End With
    Application.CutCopyMode = False

    Rng.AutoFilter Field:=6
    End If
    End If
    Next i
    End With

    Rng.Parent.AutoFilterMode = False

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,743

    Re: Provide user defined function for below vba code

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] User defined function returns an error on a standard function used in it.
    By pb48 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-23-2013, 01:35 PM
  2. User Defined Function
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2010, 01:57 AM
  3. Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 PM
  4. user defined function
    By delmac in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-11-2006, 11:35 AM
  5. Need to open the Function Arguments window from VBA for a user defined function.
    By korrin.anderson@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2006, 10:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1