+ Reply to Thread
Results 1 to 3 of 3

Using a MATCH in VBA is driving me crazy!

  1. #1
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Using a MATCH in VBA is driving me crazy!

    I have been trying to use a MATCH function as part of my macro and can NOT get the syntax right. Or else I've created a bigger issue; I'm not sure which. I'll attach a workbook - The first page is how I start out and the second page is how I need to end up. I've got the 4 rows inserting at the top and got them formatting correctly. I need to ultimately have a SUMIF fill the cells in row 3 with the results summing column J. (Apparel and GOH are combined and Flat and Security Mark are combined), but I THINK that, in order to do that, I need to specify the end of each section, to tell the SUMIF where to stop looking, right? That's where I'm running into the problem.

    I'm trying to use MATCH to get the row # of the end of each of the sections: Apparel, Cosmetic, etc. If I put a MATCH formula in a cell on the worksheet it works fine. I've tried to translate it into VBA, but am failing miserably. Here is my current, non-working code:
    Please Login or Register  to view this content.
    ( I just thought I'd try to get it to identify the first 2 sections before carrying on to the rest of them).
    The problem comes at the 2 red lines. I've tried changing the syntax to EVERY option I can imagine and, every time I change it, I get a different error message! When I F8 through the current code gives a 2042 error on both of those lines.

    I've been googling for probably 2 hrs and am no closer to an answer.

    Can anyone see the (probably simple) error I'm making?

    Thanks!

    Jenny
    Attached Files Attached Files
    Last edited by zookeepertx; 01-13-2015 at 02:18 PM.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Using a MATCH in VBA is driving me crazy!

    Try this.....
    Please Login or Register  to view this content.
    Does this help?
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Using a MATCH in VBA is driving me crazy!

    Huh - I thought I had tried that, but I've made so many changes that I forget. That does work - YAY!

    Here's a weird thing, though. If I just type the MATCH formula into a cell in the spreadsheet, it finds the row # of the SECOND instance of the word (Apparel, in the first case). (Actually, it finds how many rows below row 5 that last instance is). But in the macro, it finds the FIRST instance of the word (also how many rows below row 5 that first instance is). I actually need the SECOND instance.

    Also, I guess I need to start at A1 instead of A5, so it gives the correct row number. But since I've inserted a row that also says APPAREL, I actually need to find the third instance, only in the case of APPAREL. But the second instance of each of the other words. Do you know how to do that?

    Have I been totally confusing? I hope not.

    Thank you for the progress so far!

    Jenny
    Last edited by zookeepertx; 01-13-2015 at 05:36 PM.

+ 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. Match function works while the "=" says True! Driving me crazy!
    By tony.nz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2014, 02:17 PM
  2. This is driving me crazy!!
    By rtausch in forum Excel General
    Replies: 0
    Last Post: 10-15-2008, 06:33 PM
  3. please please help driving me crazy
    By jilly jess in forum Excel General
    Replies: 1
    Last Post: 01-14-2007, 09:59 AM
  4. Formula is driving me crazy?????
    By Chris Watson in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 02-13-2006, 03:20 PM
  5. Driving me crazy!
    By RobEdgeler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-03-2005, 05:19 PM

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