+ Reply to Thread
Results 1 to 3 of 3

Help about macro and filtering data

Hybrid View

bitaz Help about macro and... 11-04-2011, 01:03 AM
JBeaucaire Re: Help about macro and... 11-04-2011, 01:48 AM
bitaz Re: Help about macro and... 11-04-2011, 02:14 AM
  1. #1
    Registered User
    Join Date
    11-04-2011
    Location
    jakarta
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    5

    Question Help about macro and filtering data

    Dear all,
    I need to make address database for my clients. I put a box in Sheet 2 so that I can print it out to glue it in an envelope. So I want the box to be contained automatically with the Company name and address that I select in filtered cell in Sheet 1. So I can only select the name of the Company in B1 (Sheet 1) and the Company name and address will show automatically inside the text box in Sheet 2. Please help about the macro. Giga thanks in advance.
    Attached Files Attached Files
    Last edited by bitaz; 11-04-2011 at 02:19 AM. Reason: attachment

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help about macro and filtering data

    1) Put this formula in E1 of Sheet1:

    =IF(SUBTOTAL(109,A:A)>MAX(A:A),"",SUBTOTAL(109,A:A)+1)

    2) Right-click the sheet1 tab and select VIEW CODE

    3) Paste in the event macro:
    Option Explicit
    
    Private Sub Worksheet_Calculate()
        
        If [E1] = "" Then
            Sheets("Sheet2").Shapes(1).TextFrame.Characters.Text = ""
        Else
            With Range("A" & [E1])
                Sheets("Sheet2").Shapes(1).TextFrame.Characters.Text = _
                  .Value & Chr(10) & .Offset(, 1).Value & Chr(10) & .Offset(, 2).Value
            End With
        End If
        
    End Sub
    4) Close the VBA editor and save your workbook as a .xlsm format so the macro will continue to work.

    5) Now any changes the filter will update the text box on sheet2.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-04-2011
    Location
    jakarta
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    5

    Re: Help about macro and filtering data

    Whoaaa! It does work.
    Thank you sooooo much for helping. Thanks. :D :D

+ 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