+ Reply to Thread
Results 1 to 2 of 2

Macro to subtract data from cells

  1. #1
    Registered User
    Join Date
    09-23-2005
    Posts
    2

    Cool Macro to subtract data from cells

    I need a macro to take away data from my spreadsheet. The spreadsheet is created from data i have emailed to me from a form on my website.

    For example, each set of cells would have something like this with each line in each cell

    F_name: John Smith
    Unit: Computer Tech
    Comments: blah blah blah

    I would like the macro to take away the "F_name:, Unit:, and Comments:" text leaving only the valuable information that i can then make a good informative sheet with.

    I am an experienced excel user so if you have any ideas please let me know.

    Thanks

  2. #2
    DoctorG
    Guest

    RE: Macro to subtract data from cells

    I think that a piece of code which traverses each row of your spreadsheet and
    checks the beginning of each cell's value against your standard values will
    do what you need.

    i.e.
    (A column is an index, B column is the name field and so on)
    line_counter=1
    While line_counter < range("blah").rows.count

    Activecell.Offset(1,0).Select // move down one row in A column

    if Left(Activecell.Offset(0,1).Value,12)="Your name : " then
    Activecell.Offset(0,1).Value=MID(Activecell.Offset(0,1).Value,13,999) //
    this leaves the remaining characters after the unwanted part in the B column
    cell
    endif

    line_counter=line_counter+1

    Wend

    Hope this helps

+ 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