Results 1 to 4 of 4

VBA - search specific value in cell and copy 10 lines (downward and sideward)

Threaded View

juicersz VBA - search specific value... 04-10-2013, 06:41 AM
davesexcel Re: VBA - search specific... 04-10-2013, 11:09 PM
juicersz Re: VBA - search specific... 04-10-2013, 11:36 PM
juicersz Re: VBA - search specific... 04-11-2013, 01:33 AM
  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    Kuala Lumpur
    MS-Off Ver
    Excel 2010
    Posts
    7

    VBA - search specific value in cell and copy 10 lines (downward and sideward)

    Hi,

    I've recorded a macro where the pivot table will automatically constructed. However, the raw data is not always the same (total lines are different) therefore the grand total sum will not always be on the same line (refer below hard code range HC5 and B386). If this is a variable, how do I make the macro to search for the "grand total" word, sort from largest to smallest numbers and copy the next 10 cells (downward and sideward, separately of course.)

    The reason I want to copy due to the template that I want to paste the data into the template.

    'to select grand total at the bottom of the pivot table
        Range("HC5").Select ActiveSheet.PivotTables("PivotTable2").PivotFields("BidClient").AutoSort _
            xlDescending, "Sum of Volume", ActiveSheet.PivotTables("PivotTable2"). _
            PivotColumnAxis.PivotLines(210), 1
    
    'to select grand total at the top right of pivot table
        Range("B386").Select ActiveSheet.PivotTables("PivotTable2").PivotFields("AskClient").AutoSort _
            xlDescending, "Sum of Volume", ActiveSheet.PivotTables("PivotTable2"). _
            PivotRowAxis.PivotLines(382), 1
    I have attached the image foryour ease of reference.

    sample1.jpg
    Many thanks.
    Last edited by juicersz; 04-10-2013 at 11:35 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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