+ Reply to Thread
Results 1 to 5 of 5

VBA Loop & Offset Syntax

  1. #1
    Registered User
    Join Date
    07-21-2010
    Location
    EARTH
    MS-Off Ver
    MS EARTH
    Posts
    2

    VBA Loop & Offset Syntax

    I need a vba command that searches column J for a text value, when the value is identified the row is selected and cut and pasted into_
    a new worksheet. A new worksheet should be created for every unique value of column J. Second part: Lets say column say had
    5 unique values so there are 5 new worksheets. Each worksheet contains 30-50 rows (and 10 columns) for example, I need to sort the rows based on 3 criteria
    this is easily accomplished by the Sort dialogue box however it creates static references in the vba code (i.e., A2:A50) however
    the references need to be dynamic so that once a new set of data is worked on with this macro, all the rows (>50 if needed) could
    be analyzed. I've tried using the offset function to address this last problem but I cannot seem to get the synthax down.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: VBA Loop & Offset Syntax

    searches column J for a text value
    does that mean some values in column J are not text . what are they . I presume they are not blanks but logical values or numbers.

    I also do not know what is the configuration of your data. I have created a sample configuration. I have sent the whole workbook and you can download from this webpage(as it may perhaps be large for parking in this newsgroup). you see the data in sheet1

    http://www.speedyshare.com/files/234...bgintheusa.xls

    the macro "test" is in the vb editor module. the second macro "undo" will remove the results of the macro "test". at present the workbooks, as it is, after running the macro "test"
    for rechecking
    1. run "undo"
    2. run "test"

    the macros are also given below for completions' sake

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    YOUR COMMENTS PLEASE.

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Thumbs up Re: VBA Loop & Offset Syntax

    Hi bgintheusa;

    Here's a macro that should be easier to step through and understand what is happening. It's probably not as efficient as venkat1926's, but it might be easier to modify to fit your needs.

    I did this off the top of my head, so backup first.
    Please Login or Register  to view this content.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  4. #4
    Registered User
    Join Date
    07-21-2010
    Location
    EARTH
    MS-Off Ver
    MS EARTH
    Posts
    2

    Re: VBA Loop & Offset Syntax

    So far this example I found online has worked the best,

    Please Login or Register  to view this content.
    Last edited by bgintheusa; 07-26-2010 at 10:34 AM. Reason: spelling

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: VBA Loop & Offset Syntax

    Hi bgintheusa;

    Just letting you know that it's against the rules for anyone to reply to your post if it doesn't contain code tags around the code. And please indent your code so that it's easier to read.

    The rules are here http://www.excelforum.com/forum-rule...rum-rules.html

+ 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