+ Reply to Thread
Results 1 to 2 of 2

Creating a function

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2013
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007
    Posts
    32

    Creating a function

    I want to create a function for the following code. Is it possible?

    Sheets("Sample data").Select
        Range("B6:T6").Select
        Selection.AutoFilter
        ActiveSheet.Range("$B$6:$T$500").AutoFilter Field:=10, Criteria1:=Sheets("analyst Report").Range("C2")
        ActiveSheet.Range("$B$6:$T$500").AutoFilter Field:=1, Criteria1:=">=" & r, Operator:=xlAnd, Criteria2:="<=" & s, Operator:=xlFilterValues
        Range("I6").Select
        Selection.End(xlDown).Select
        If IsEmpty(ActiveCell) = True Then
        Sheets("analyst report").Select
        Range("C3").Value = "No activity in current period"
        
        ElseIf ActiveCell.Row = 7 Then
        Range("I7").Select
        Selection.Copy
        Sheets("Analyst Report").Select
        Range("c10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Sample data").Select
        Range("N7:T7").Select
        Selection.Copy
        Sheets("Analyst Report").Select
        Range("D10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        
        Sheets("Sample data").Select
        Range("A6").Select
        
        Sheets("Analyst Report").Select
        Range("I24").Select
        
        
        ElseIf IsEmpty(ActiveCell) = False Then
        Range("I7").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Sheets("Analyst Report").Select
        Range("c10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Sample data").Select
        Range("N7:T7").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Sheets("Analyst Report").Select
        Range("D10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False:
    Last edited by rbs123; 07-03-2013 at 12:58 AM. Reason: adding code tags

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Creating a function

    Hi, rbs123,

    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

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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