+ Reply to Thread
Results 1 to 12 of 12

Macro to insert text in a field if another field is > 0.

  1. #1
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    213

    Macro to insert text in a field if another field is > 0.

    I have a situation where I need to analyze a range (F9:Q100) and if the cell contents are > 0 insert the header into another field . (See attached picture) Example: Referencing the attached picture, I would like column R to have the following text:

    R8 PACKAGING CHANGE, CONTRACT CHANGE, UOM CHANGE
    R9
    R10 ITEM ADD, VENDOR CHANGE, ACTIVATE
    R11
    R12
    R13 CONTRACT CHANGE
    R14
    R15 PACKING CHANGE
    R16

    Sample.png

    I am having trouble writing the code to do this in VB. Any help would be appreciated.

    Thanks,

    Met

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    Or do you mean?

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    213

    Re: Macro to insert text in a field if another field is > 0.

    John,

    Thanks for the quick response. However, I was unable to get either code to process the data like I need it to. (All of the cells under column "R" remain blank when I am expecting some to have text.)

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    Can you attach a sample file with some dummy data?

  6. #6
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    213

    Re: Macro to insert text in a field if another field is > 0.

    Book1.xlsm

    Please find attached a basic sample file. I included Macro1 in the workbook.

    Thanks,

    Met

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    Met:

    It didn't work because I assume your header information was in row 1.

    Try:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    213

    Re: Macro to insert text in a field if another field is > 0.

    Thanks, that did capture part of the information. However, the cell is being overwritten if multiple columns are tagged. For example, if you run the script in book1.xlsm the results listed in R9 will be: UOM CHANGE. Ultimately, what I want to see would be: PACKAGING CHANGE, CONTRACT CHANGE, UOM CHANGE.

    I do appreciate the help you have provided.

    Thanks,

    Met

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    Try:

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    Try:

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    213

    Re: Macro to insert text in a field if another field is > 0.

    Perfect! I appreciate your help.

    Met

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to insert text in a field if another field is > 0.

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Replies: 3
    Last Post: 07-22-2014, 04:23 PM
  2. Replies: 2
    Last Post: 03-18-2014, 03:58 PM
  3. Replies: 0
    Last Post: 06-26-2012, 09:06 PM
  4. Replies: 3
    Last Post: 03-03-2012, 12:16 PM
  5. Conditional Insert text in field
    By resnostyle in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-18-2009, 04:06 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