+ Reply to Thread
Results 1 to 10 of 10

VBA MAcro help - using a variable starting point

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    VBA MAcro help - using a variable starting point

    I have a macro that is used to clean up a 268+ page text document. The macro deletes all of the repetitive page headers by using the Filter function and then deleting the non-essential rows. Each month the text file is a diffeent length and the starting row to be deleted once the filtering has been done, varies. Is there a way to be non-specific on which row to start the deleting process.

    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$7:$E$20000").AutoFilter Field:=1, Criteria1:=Array( _
    " ", "ANNUAL", "DATE:", "INV NO. I", "MONTHLY", "QUARTERLY", "SEMI-ANNU", "SUBSIDIAR", "SUPP", _
    "SUPPLIER", "TIME:", "TOTA", "TOTAL DUE", "="), Operator:=xlFilterValues
    Range("A48").Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Selection.EntireRow.Delete
    Range("B5").Select

    The Range "A48" is where I have the issue. The "A" will always be constant but the "48" will vary each month.

    Thx

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: VBA MAcro help - using a variable starting point

    You can use logic instead to find that point, yes.

    So my question would then be, how do YOU determine where to start that?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    Re: VBA MAcro help - using a variable starting point

    The starting point is determined by the first row after the filtering occurs. If the first row below the column headers is row 48, then everything is ok. If it is less then row 48, then the macro doesn't work properly for the rows above row 48. It works ok for everything below row 48. Thx

  4. #4
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    Re: VBA MAcro help - using a variable starting point

    I'm new at VBA. Any suggestions on how to write the commands for this process?. Thx

  5. #5
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: VBA MAcro help - using a variable starting point

    If it is ALWAYS row 48, then where is the disconnect?

  6. #6
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    Re: VBA MAcro help - using a variable starting point

    Sorry for the confusion. When the macro was first created, the start row happened to be 48. However, since then, each month the start row has changed. Last month it was 37, the month before it was row 51. It is always the first row below the column headers when the filter is applied.

  7. #7
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: VBA MAcro help - using a variable starting point

    Sorry, you need to post a sample workbook, otherwise I ca'nt help much.I have no idea what a column header looks like for you so I cant help you use VBA to find that cell.

    What I would do with a sample workbook, is follow your guidance to determine WHAT is the starting point, then translate that into VBA. I cant determine what that is in excel, just words in the forum, which makes it divvidult for me to help you translate into VBA, if that makes sense.


    If you can easily identify the starting point manually, I think we should be able to do it pretty easily with VBA...
    Last edited by mikeTRON; 03-27-2015 at 11:17 AM.

  8. #8
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    Re: VBA MAcro help - using a variable starting point

    Hi. I am receiving an error message when I try to upload my sample file. I will try from a different computer over the weekend. Thanks for your help so far.

  9. #9
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    Re: VBA MAcro help - using a variable starting point

    Hi, attached is my sample file. I have highlighted the rows that are to be deleted. Hope you can help.
    Thx
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-26-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    12

    Re: VBA MAcro help - using a variable starting point

    Hi

    Does anyone have any ideas on how to fix this issue. Thx

+ 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. code for variable starting point
    By Sebastian1942 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-25-2013, 11:04 AM
  2. Replies: 0
    Last Post: 09-16-2013, 10:10 AM
  3. [SOLVED] Adding filter to all sheets with variable starting point
    By SeaniGeld in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2013, 04:20 AM
  4. Index/Match to find Starting Point of Average, Ending Point of Average Variable
    By tgentry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-09-2012, 01:04 AM
  5. Starting Point of macro
    By Turin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2005, 08:05 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